brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Support for adding YAML defined p...
Date Thu, 21 Aug 2014 16:30:08 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/124#discussion_r16550195
  
    --- Diff: core/src/main/java/brooklyn/catalog/internal/CatalogItemBuilder.java ---
    @@ -0,0 +1,87 @@
    +/*
    + * 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 brooklyn.catalog.internal;
    +
    +import com.google.common.base.Preconditions;
    +
    +public class CatalogItemBuilder<CatalogItemType extends CatalogItemDtoAbstract<?,
?>> {
    +    private CatalogItemType dto;
    +
    +    public static CatalogItemBuilder<CatalogEntityItemDto> newEntity() {
    +        return new CatalogItemBuilder<CatalogEntityItemDto>(new CatalogEntityItemDto());
    +    }
    +
    +    public static CatalogItemBuilder<CatalogTemplateItemDto> newTemplate() {
    +        return new CatalogItemBuilder<CatalogTemplateItemDto>(new CatalogTemplateItemDto());
    +    }
    +
    +    public static CatalogItemBuilder<CatalogPolicyItemDto> newPolicy() {
    +        return new CatalogItemBuilder<CatalogPolicyItemDto>(new CatalogPolicyItemDto());
    +    }
    +
    +    public CatalogItemBuilder(CatalogItemType dto) {
    +        this.dto = dto;
    +        this.dto.libraries = new CatalogLibrariesDto();
    +    }
    +
    +    public CatalogItemBuilder<CatalogItemType> registeredTypeName(String registeredType)
{
    +        dto.registeredType = registeredType;
    +        return this;
    +    }
    +
    +    public CatalogItemBuilder<CatalogItemType> name(String name) {
    +        dto.name = name;
    +        return this;
    +    }
    +
    +    public CatalogItemBuilder<CatalogItemType> description(String description)
{
    +        dto.description = description;
    +        return this;
    +    }
    +
    +    public CatalogItemBuilder<CatalogItemType> iconUrl(String iconUrl) {
    +        dto.iconUrl = iconUrl;
    +        return this;
    +    }
    +
    +    public CatalogItemBuilder<CatalogItemType> libraries(CatalogLibrariesDto libraries)
{
    +        dto.libraries = libraries;
    +        return this;
    +    }
    +
    +    public void plan(String yaml) {
    +        dto.planYaml = yaml;
    +    }
    +
    +    public CatalogItemType build() {
    +        Preconditions.checkNotNull(dto.registeredType);
    --- End diff --
    
    If `registeredType` is compulsory, then maybe `newPolicy()` should take it as a parameter?
No strong feelings.


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