1 package org.apache.maven.doxia.wrapper;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.Serializable;
23 import java.util.Objects;
24
25 import static org.codehaus.plexus.util.StringUtils.isNotEmpty;
26
27
28
29
30
31
32 abstract class AbstractWrapper
33 implements Serializable
34 {
35 public static final String AUTO_FORMAT = "auto";
36
37 private String format;
38
39 private String[] supportedFormat;
40
41
42
43
44
45
46 AbstractWrapper( String format, String[] supportedFormat )
47 {
48 this.format = ( isNotEmpty( format ) ? format : AUTO_FORMAT );
49 if ( supportedFormat == null )
50 {
51 throw new IllegalArgumentException( "supportedFormat is required" );
52 }
53 this.supportedFormat = supportedFormat;
54 }
55
56
57
58
59 public String getFormat()
60 {
61 return this.format;
62 }
63
64
65
66
67 void setFormat( String format )
68 {
69 this.format = format;
70 }
71
72
73
74
75 public String[] getSupportedFormat()
76 {
77 return supportedFormat;
78 }
79
80
81
82
83 void setSupportedFormat( String[] supportedFormat )
84 {
85 this.supportedFormat = supportedFormat;
86 }
87
88
89 @Override
90 public boolean equals( Object other )
91 {
92 if ( this == other )
93 {
94 return true;
95 }
96 if ( other == null || getClass() != other.getClass() )
97 {
98 return false;
99 }
100
101 AbstractWrapper that = (AbstractWrapper) other;
102 return Objects.equals( getFormat(), that.getFormat() );
103 }
104
105
106 @Override
107 public int hashCode()
108 {
109 return Objects.hash( getFormat() );
110 }
111
112
113 @Override
114 public String toString()
115 {
116 return "format = '" + getFormat() + "'";
117 }
118 }