You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by neykov <gi...@git.apache.org> on 2015/11/02 13:47:48 UTC

[GitHub] incubator-brooklyn pull request: Introduce a type registry as a si...

Github user neykov commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/993#discussion_r43624594
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/typereg/RegisteredTypePredicates.java ---
    @@ -0,0 +1,191 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.core.typereg;
    +
    +import javax.annotation.Nullable;
    +
    +import org.apache.brooklyn.api.catalog.BrooklynCatalog;
    +import org.apache.brooklyn.api.entity.Application;
    +import org.apache.brooklyn.api.entity.Entity;
    +import org.apache.brooklyn.api.location.Location;
    +import org.apache.brooklyn.api.mgmt.ManagementContext;
    +import org.apache.brooklyn.api.policy.Policy;
    +import org.apache.brooklyn.api.typereg.RegisteredType;
    +import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
    +
    +import com.google.common.base.Function;
    +import com.google.common.base.Predicate;
    +import com.google.common.base.Predicates;
    +
    +public class RegisteredTypePredicates {
    +
    +    public static Predicate<RegisteredType> deprecated(final boolean deprecated) {
    +        return new DeprecatedEqualTo(deprecated);
    +    }
    +
    +    private static class DeprecatedEqualTo implements Predicate<RegisteredType> {
    +        private final boolean deprecated;
    +        
    +        public DeprecatedEqualTo(boolean deprecated) {
    +            this.deprecated = deprecated;
    +        }
    +        @Override
    +        public boolean apply(@Nullable RegisteredType item) {
    +            return (item != null) && item.isDeprecated() == deprecated;
    +        }
    +    }
    +
    +    public static Predicate<RegisteredType> disabled(boolean disabled) {
    +        return new DisabledEqualTo(disabled);
    +    }
    +
    +    private static class DisabledEqualTo implements Predicate<RegisteredType> {
    +        private final boolean disabled;
    +        
    +        public DisabledEqualTo(boolean disabled) {
    +            this.disabled = disabled;
    +        }
    +        @Override
    +        public boolean apply(@Nullable RegisteredType item) {
    +            return (item != null) && item.isDisabled() == disabled;
    +        }
    +    }
    +
    +    @SuppressWarnings("unused")
    +    private static final Function<RegisteredType,String> ID_OF_ITEM_TRANSFORMER_ANONYMOUS = new Function<RegisteredType, String>() {
    --- End diff --
    
    Don't see the point of this one?


---
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.
---