3232import java .util .Map ;
3333import java .util .Optional ;
3434import java .util .Set ;
35+ import java .util .UUID ;
3536
3637import com .google .common .collect .ImmutableList ;
3738
@@ -49,6 +50,8 @@ public class RamlType {
4950
5051 private List <String > values ;
5152
53+ private String pattern ;
54+
5255 public RamlType (final String type ) {
5356 this .type = type ;
5457 }
@@ -65,6 +68,8 @@ public Map<String, RamlType> properties() {
6568 return properties ;
6669 }
6770
71+ public String pattern (){ return pattern ; }
72+
6873 @ Override
6974 public boolean equals (final Object obj ) {
7075 if (obj instanceof RamlType ) {
@@ -115,6 +120,9 @@ public String toString(int level) {
115120 if (values != null ) {
116121 buff .append (indent (level )).append ("enum: " ).append (values .toString ()).append ("\n " );
117122 }
123+ if (pattern != null ) {
124+ buff .append (indent (level )).append ("pattern: " ).append (pattern ).append ("\n " );
125+ }
118126 buff .setLength (buff .length () - 1 );
119127 return buff .toString ();
120128 }
@@ -196,6 +204,10 @@ private static RamlType simpleParse(final Type type) {
196204 enums .add (((Enum ) value ).name ());
197205 }
198206 complex .values = enums ;
207+ } else if (UUID .class .isAssignableFrom (rawType )) {
208+ complex = new RamlType ("string" );
209+ complex .name = "uuid" ;
210+ complex .pattern = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$" ;
199211 } else {
200212 complex = new RamlType ("object" );
201213 complex .name = rawType .getSimpleName ();
@@ -282,6 +294,12 @@ private static Class<?> componentType(final Type type) {
282294 return null ;
283295 }
284296
297+ public boolean isCustom () {
298+ return properties != null ||
299+ values != null ||
300+ pattern != null ;
301+ }
302+
285303 public boolean isObject () {
286304 return properties != null ;
287305 }
0 commit comments