brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahgittin <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Flesh out type creation using the...
Date Tue, 17 Nov 2015 12:04:01 GMT
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1017#discussion_r45051796
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/typereg/RegisteredTypes.java ---
    @@ -66,180 +94,131 @@ public static RegisteredType of(CatalogItem<?, ?> item) {
             type.deprecated = item.isDeprecated();
     
             // TODO
    -        // javaType, specType, registeredTypeName ...
    -        // tags ?
    +        // probably not: javaType, specType, registeredTypeName ...
    +        // maybe: tags ?
             return type;
         }
     
    -    /** Visitor adapter which can be used to ensure all kinds are supported */
    -    public static abstract class RegisteredTypeKindVisitor<T> {
    -        public T visit(RegisteredType type) {
    -            if (type==null) throw new NullPointerException("Registered type must not
be null");
    -            if (type instanceof RegisteredSpecType) {
    -                return visitSpec((RegisteredSpecType)type);
    -            }
    -            // others go here
    -            throw new IllegalStateException("Unexpected registered type: "+type.getClass());
    -        }
    -
    -        protected abstract T visitSpec(RegisteredSpecType type);
    -        
    -        // TODO beans, others
    +    /** Preferred mechanism for defining a bean {@link RegisteredType} */
    +    public static RegisteredType bean(String symbolicName, String version, TypeImplementationPlan
plan, @Nullable Class<?> superType) {
    +        return addSuperType(new BasicRegisteredType(RegisteredTypeKind.BEAN, symbolicName,
version, plan), superType);
         }
         
    -    public static RegisteredTypeKind getKindOf(RegisteredType type) {
    -        return new RegisteredTypeKindVisitor<RegisteredTypeKind>() {
    -            @Override protected RegisteredTypeKind visitSpec(RegisteredSpecType type)
{ return RegisteredTypeKind.SPEC; }
    -        }.visit(type);
    +    public static RegisteredType spec(String symbolicName, String version, TypeImplementationPlan
plan, @Nullable Class<?> superType) {
    --- End diff --
    
    i'd like to be able to make them non-null, when the creation API is good enough


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message