If you think the Android project JBoss-Admin-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* JBoss Admin//www.java2s.com
* Copyright 2013, Christos Vasilakis, and individual contributors
*
* 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 org.cvasilak.jboss.mobile.app.model;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Comparator;
publicclass OperationParameter extends ManagementModelBase {
privateboolean isNillable;
privateboolean isRequired;
privateboolean isAddParameter;
private Object defaultValue;
publicstaticfinal Comparator<OperationParameter> REQUIRED_COMPARATOR = new Comparator<OperationParameter>() {
@Override
publicint compare(OperationParameter lhs, OperationParameter rhs) {
if (lhs.isRequired() && !rhs.isRequired())
return -1;
elseif (!lhs.isRequired() && rhs.isRequired())
return 1;
return 0;
}
};
publicstaticfinal Parcelable.Creator<OperationParameter> CREATOR
= new Parcelable.Creator<OperationParameter>() {
public OperationParameter createFromParcel(Parcel in) {
returnnew OperationParameter(in);
}
public OperationParameter[] newArray(int size) {
returnnew OperationParameter[size];
}
};
public OperationParameter() {
}
public OperationParameter(Parcel in) {
readFromParcel(in);
}
public OperationParameter(String name) {
this.name = name;
}
publicboolean isNillable() {
return isNillable;
}
publicvoid setNillable(boolean nillable) {
isNillable = nillable;
}
publicboolean isRequired() {
return isRequired;
}
publicvoid setRequired(boolean required) {
isRequired = required;
}
publicboolean isAddParameter() {
return isAddParameter;
}
publicvoid setAddParameter(boolean addParameter) {
isAddParameter = addParameter;
}
public Object getDefaultValue() {
return defaultValue;
}
publicvoid setDefaultValue(Object defaultValue) {
this.defaultValue = defaultValue;
}
publicvoid setDefaultValue(JsonElement value) {
if (value instanceof JsonPrimitive) {
JsonPrimitive primitive = (JsonPrimitive) value;
if (primitive.isNumber()) {
try {
this.defaultValue = NumberFormat.getInstance().parse(primitive.getAsString());
} catch (ParseException e) {
}
} elseif (primitive.isBoolean()) {
this.defaultValue = primitive.getAsBoolean();
} elseif (primitive.isString()) {
this.defaultValue = primitive.getAsString();
}
}
}
@Override
publicvoid readFromParcel(Parcel in) {
super.readFromParcel(in);
isNillable = (in.readInt() != 0);
isRequired = (in.readInt() != 0);
isAddParameter = (in.readInt() != 0);
value = in.readValue(null);
}
@Override
publicvoid writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeInt(isNillable ? 1 : 0);
out.writeInt(isRequired ? 1 : 0);
out.writeInt(isAddParameter ? 1 : 0);
out.writeValue(value);
}
}