X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fsal%2Fyang-prototype%2Fcode-generator%2Fbinding-generator-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fbinding%2Fgenerator%2Futil%2FTypes.java;h=2e5bbf0a07a6f0a73d41af7f92c510880aae6963;hb=ff1b4a79cca00743a00c3b0b1100bd0ab2b2fb31;hp=87bb47cb76e6819f9b93fd0180154b4545c25bd8;hpb=b571c5f3e6e9b2dcf2cff2314537c7b1c61533b4;p=controller.git diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/Types.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/Types.java index 87bb47cb76..2e5bbf0a07 100644 --- a/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/Types.java +++ b/opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/Types.java @@ -11,31 +11,36 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl; import org.opendaylight.controller.sal.binding.model.api.ConcreteType; +import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject; import org.opendaylight.controller.sal.binding.model.api.ParameterizedType; import org.opendaylight.controller.sal.binding.model.api.Type; +import org.opendaylight.controller.sal.binding.model.api.WildcardType; import org.opendaylight.controller.yang.binding.Augmentable; import org.opendaylight.controller.yang.binding.Augmentation; +import org.opendaylight.controller.yang.binding.BaseIdentity; import org.opendaylight.controller.yang.binding.DataObject; -public class Types { +public final class Types { private static final Type SET_TYPE = typeForClass(Set.class); private static final Type LIST_TYPE = typeForClass(List.class); private static final Type MAP_TYPE = typeForClass(Map.class); - public static final Type DATA_OBJECT = typeForClass(DataObject.class); - - private Types() { - } public static ConcreteType voidType() { return new ConcreteTypeImpl(Void.class.getPackage().getName(), Void.class.getSimpleName()); } + public static final Type primitiveType(final String primitiveType) { + return new ConcreteTypeImpl("", primitiveType); + } + + /** * Returns an instance of {@link ConcreteType} describing the class - * + * * @param cls * Class to describe * @return Description of class @@ -48,7 +53,7 @@ public class Types { /** * Returns an instance of {@link ParameterizedType} describing the typed * {@link Map} - * + * * @param keyType * Key Type * @param valueType @@ -62,7 +67,7 @@ public class Types { /** * Returns an instance of {@link ParameterizedType} describing the typed * {@link Set} with concrete type of value. - * + * * @param valueType * Value Type * @return Description of generic type instance of Set @@ -74,7 +79,7 @@ public class Types { /** * Returns an instance of {@link ParameterizedType} describing the typed * {@link List} with concrete type of value. - * + * * @param valueType * Value Type * @return Description of type instance of List @@ -83,8 +88,15 @@ public class Types { return parameterizedTypeFor(LIST_TYPE, valueType); } + public static GeneratedTransferObject getBaseIdentityTO() { + Class cls = BaseIdentity.class; + GeneratedTOBuilderImpl gto = new GeneratedTOBuilderImpl(cls.getPackage().getName(), + cls.getSimpleName()); + return gto.toInstance(); + } + /** - * + * * @param type * @param parameters * @return @@ -93,17 +105,21 @@ public class Types { Type... parameters) { return new ParametrizedTypeImpl(type, parameters); } - + + public static WildcardType wildcardTypeFor(String packageName, String typeName) { + return new WildcardTypeImpl(packageName, typeName); + } + public static ParameterizedType augmentableTypeFor(Type valueType) { final Type augmentable = typeForClass(Augmentable.class); return parameterizedTypeFor(augmentable, valueType); } - + public static ParameterizedType augmentationTypeFor(Type valueType) { final Type augmentation = typeForClass(Augmentation.class); return parameterizedTypeFor(augmentation, valueType); } - + private static class ConcreteTypeImpl extends AbstractBaseType implements ConcreteType { private ConcreteTypeImpl(String pkName, String name) { @@ -134,4 +150,12 @@ public class Types { } } + + private static class WildcardTypeImpl extends AbstractBaseType + implements WildcardType { + public WildcardTypeImpl(String packageName, String typeName) { + super(packageName, typeName); + } + } + }