![JAR search and dependency download from the Maven repository](/logo.png)
com.cloudbees.sdk.commands.config.model.ResourceSettings Maven / Gradle / Ivy
/*
* Copyright 2010-2013, CloudBees Inc.
*
* Licensed 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 com.cloudbees.sdk.commands.config.model;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* @author Fabian Donze
*/
public class ResourceSettings {
@XStreamAsAttribute
private String name;
@XStreamAsAttribute
private String value;
@XStreamAsAttribute
private String type;
@XStreamAsAttribute
private String scope;
@XStreamAsAttribute
private String auth;
@XStreamAsAttribute
private String delim;
@XStreamImplicit(itemFieldName="param")
private List parameters;
public ResourceSettings(String name, String type) {
this.name = name;
this.type = type;
parameters = new ArrayList();
}
public ResourceSettings(String name, String type, String value) {
this.name = name;
this.type = type;
this.value = value;
parameters = new ArrayList();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type == null ? "internal" : type;
}
public void setType(String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getAuth() {
return auth;
}
public void setAuth(String auth) {
this.auth = auth;
}
public String getDelim() {
return delim;
}
public void setDelim(String delim) {
this.delim = delim;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public List getParameters() {
if (parameters == null)
parameters = new ArrayList();
return parameters;
}
public void setParameters(List parameters) {
this.parameters = parameters;
}
public void setParameter(String name, String value) {
ParameterSettings parameterSettings = getParameter(name);
if(parameterSettings != null)
parameterSettings.setValue(value);
else
addParameter(new ParameterSettings(name, value));
}
private void addParameter(ParameterSettings param)
{
getParameters().add(param);
}
public ParameterSettings getParameter(String name)
{
for(ParameterSettings param : getParameters())
{
if(param.getName().equals(name))
return param;
}
return null;
}
public void deleteParameter(String name) {
Iterator it = getParameters().iterator();
while (it.hasNext()) {
if (it.next().getName().equals(name)) {
it.remove();
}
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ResourceSettings that = (ResourceSettings) o;
if (auth != null ? !auth.equals(that.auth) : that.auth != null) return false;
if (delim != null ? !delim.equals(that.delim) : that.delim != null) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
if (parameters != null ? !parameters.equals(that.parameters) : that.parameters != null) return false;
if (scope != null ? !scope.equals(that.scope) : that.scope != null) return false;
if (type != null ? !type.equals(that.type) : that.type != null) return false;
if (value != null ? !value.equals(that.value) : that.value != null) return false;
return true;
}
@Override
public int hashCode() {
int result = value != null ? value.hashCode() : 0;
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (auth != null ? auth.hashCode() : 0);
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (delim != null ? delim.hashCode() : 0);
result = 31 * result + (scope != null ? scope.hashCode() : 0);
result = 31 * result + (parameters != null ? parameters.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "ResourceSettings{" +
"value='" + value + '\'' +
", name='" + name + '\'' +
", auth='" + auth + '\'' +
", type='" + type + '\'' +
", delim='" + delim + '\'' +
", scope='" + scope + '\'' +
", parameters=" + parameters +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy