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

    https://github.com/apache/brooklyn-server/pull/645#discussion_r113669607
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/core/typereg/BasicManagedBundle.java ---
    @@ -0,0 +1,175 @@
    +/*
    + * 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 java.io.File;
    +import java.util.Map;
    +
    +import org.apache.brooklyn.api.mgmt.rebind.RebindSupport;
    +import org.apache.brooklyn.api.typereg.ManagedBundle;
    +import org.apache.brooklyn.api.typereg.OsgiBundleWithUrl;
    +import org.apache.brooklyn.config.ConfigKey;
    +import 
org.apache.brooklyn.core.mgmt.rebind.BasicManagedBundleRebindSupport;
    +import org.apache.brooklyn.core.objs.AbstractBrooklynObject;
    +import org.apache.brooklyn.core.objs.BrooklynObjectInternal;
    +
    +import com.google.common.annotations.Beta;
    +import com.google.common.base.MoreObjects;
    +import com.google.common.base.Objects;
    +import com.google.common.base.Preconditions;
    +
    +public class BasicManagedBundle extends AbstractBrooklynObject implements 
ManagedBundle, BrooklynObjectInternal {
    +
    +    private String symbolicName;
    +    private String version;
    +    private String url;
    +    private transient File localFileWhenJustUploaded;
    +
    +    /** Creates an empty one, with an ID, expecting other fields will be 
populated. */
    +    public BasicManagedBundle() {}
    +
    +    public BasicManagedBundle(String name, String version, String url) {
    +        if (name == null && version == null) {
    +            Preconditions.checkNotNull(url, "Either a URL or both name and 
version are required");
    +        } else {
    +            Preconditions.checkNotNull(name, "Either a URL or both name 
and version are required");
    +            Preconditions.checkNotNull(version, "Either a URL or both name 
and version are required");
    +        }
    +
    +        this.symbolicName = name;
    +        this.version = version;
    +        this.url = url;
    +    }
    +    
    +    @Override
    +    public boolean isNameResolved() {
    +        return symbolicName != null && version != null;
    +    }
    +    
    +    @Override
    +    public String getSymbolicName() {
    +        return symbolicName;
    +    }
    +
    +    public void setSymbolicName(String symbolicName) {
    +        this.symbolicName = symbolicName;
    +    }
    +    
    +    @Override
    +    public String getVersion() {
    +        return version;
    +    }
    +
    +    public void setVersion(String version) {
    +        this.version = version;
    +    }
    +    
    +    @Override
    +    public String getUrl() {
    +        return url;
    +    }
    +
    +    public void setUrl(String url) {
    +        this.url = url;
    +    }
    +
    +    /** This is cached on the object when just uploaded, then deleted 
after it has been persisted. */
    +    @Beta
    +    public void setTempLocalFileWhenJustUploaded(File 
localFileWhenJustUploaded) {
    +        this.localFileWhenJustUploaded = localFileWhenJustUploaded;
    +    }
    +    @Beta
    +    public File getTempLocalFileWhenJustUploaded() {
    +        return localFileWhenJustUploaded;
    +    }
    +    
    +    @Override
    +    public String getOsgiUniqueUrl() {
    +        return "brooklyn:"+getId();
    +    }
    +    
    +    @Override
    +    public String toString() {
    +        return MoreObjects.toStringHelper(this)
    +                .add("symbolicName", symbolicName)
    +                .add("version", version)
    +                .add("url", url)
    +                .toString();
    +    }
    +
    +    @Override
    +    public int hashCode() {
    +        return Objects.hashCode(symbolicName, version, url);
    +    }
    +
    +    @Override
    +    public boolean equals(Object obj) {
    +        if (this == obj) return true;
    +        if (obj == null) return false;
    +        if (getClass() != obj.getClass()) return false;
    +        OsgiBundleWithUrl other = (OsgiBundleWithUrl) obj;
    +        if (!Objects.equal(symbolicName, other.getSymbolicName())) return 
false;
    +        if (!Objects.equal(version, other.getVersion())) return false;
    +        if (!Objects.equal(url, other.getUrl())) return false;
    +        return true;
    +    }
    +
    +    // ---
    +    
    +    @Override
    +    public String getDisplayName() {
    +        return null;
    --- End diff --
    
    `return toString()`?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to