modules/jooby-apitool/src/main/java/org/jooby/apitool/raml/Raml.java
public RamlType define(Type type) {
    if (types == null) {
      types = new LinkedHashMap<>();
    }
    Type componentType = componentType(type);
    String typeName = MoreTypes.getRawType(componentType).getSimpleName();
    RamlType ramlType = RamlType.valueOf(typeName);
    if (ramlType.isObject()) {
      RamlType existing = types.get(typeName);
      if (existing == null) {
        ModelConverters converter = ModelConverters.getInstance();
        Property property = converter.readAsProperty(componentType);

        Map<PropertyBuilder.PropertyId, Object> args = new EnumMap<>(
            PropertyBuilder.PropertyId.class);
        for (Map.Entry<String, Model> entry : converter.readAll(componentType).entrySet()) {
          define(entry.getKey(), entry.getValue());
        }
        ramlType = define(typeName, PropertyBuilder.toModel(PropertyBuilder.merge(property, args)));
      } else {
        ramlType = existing;
      }
    }

    return type != componentType ? ramlType.toArray() : ramlType;
  }
public RamlType define(Type type) {
    if (types == null) {
      types = new LinkedHashMap<>();
    }
    Type componentType = componentType(type);
    String typeName = MoreTypes.getRawType(componentType).getSimpleName();
    RamlType ramlType = RamlType.valueOf(typeName);
    if (ramlType.isObject()) {
      RamlType existing = types.get(typeName);
      if (existing == null) {
        ModelConverters converter = ModelConverters.getInstance();
        Property property = converter.readAsProperty(componentType);

        Map<PropertyBuilder.PropertyId, Object> args = new EnumMap<>(
            PropertyBuilder.PropertyId.class);
        for (Map.Entry<String, Model> entry : converter.readAll(componentType).entrySet()) {
          define(entry.getKey(), entry.getValue());
        }
        ramlType = define(typeName, PropertyBuilder.toModel(PropertyBuilder.merge(property, args)));
      } else {
        ramlType = existing;
      }
    }

    return type != componentType ? ramlType.toArray() : ramlType;
  }
public RamlType define ( Type type ) { if ( types == null ) { types = new LinkedHashMap <> ( ) ; } Type componentType = componentType ( type ) ; String typeName = MoreTypes . getRawType ( componentType ) . getSimpleName ( ) ; RamlType ramlType = RamlType . valueOf ( typeName ) ; if ( ramlType . isObject ( ) ) { RamlType existing = types . get ( typeName ) ; if ( existing == null ) { ModelConverters converter = ModelConverters . getInstance ( ) ; Property property = converter . readAsProperty ( componentType ) ; Map < PropertyBuilder . PropertyId , Object > args = new EnumMap <> ( PropertyBuilder . PropertyId . class ) ; for ( Map . Entry < String , Model > entry : converter . readAll ( componentType ) . entrySet ( ) ) { define ( entry . getKey ( ) , entry . getValue ( ) ) ; } ramlType = define ( typeName , PropertyBuilder . toModel ( PropertyBuilder . merge ( property , args ) ) ) ; } else { ramlType = existing ; } } return type != componentType ? ramlType . toArray ( ) : ramlType ; }
Register a Java type and produces an equivalent RAML type. It returns an existing RAML type if
the Java type was registered already.

@param type Java type.
@return RAML type.
Register a Java type and produces an equivalent RAML type . It returns an existing RAML type if the Java type was registered already .