Created
April 16, 2015 15:35
-
-
Save Mugi4ok/c3cc79cecee11db2dfe8 to your computer and use it in GitHub Desktop.
RefObject
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.Serializable; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Iterator; | |
public class RefObject implements Serializable{ | |
public RefObject(int id, String name, String description, String returnType, Params[] params) { | |
this.id = id; | |
this.name = name; | |
this.description = description; | |
this.returnType = returnType; | |
this.params = params; | |
} | |
public RefObject() { | |
} | |
private int id; | |
private String name; | |
private String description; | |
private String returnType; | |
private Params[] params; | |
public int getId() { | |
return id; | |
} | |
public void setId(int id) { | |
this.id = id; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getDescription() { | |
return description; | |
} | |
public void setDescription(String description) { | |
this.description = description; | |
} | |
public String getReturnType() { | |
return returnType; | |
} | |
public void setReturnType(String returnType) { | |
this.returnType = returnType; | |
} | |
public void setParams(Params[] params) { | |
this.params = params; | |
} | |
public void setParam (int key, String param) { | |
System.out.println("Entered setParam"); | |
if(params == null || params.length == 0) { | |
System.out.println("Param[] null"); | |
params = new Params[]{new Params()}; | |
System.out.println("Created Param[]"); | |
params[0].setKey(key); | |
params[0].setValue(param); | |
System.out.println("setParam set"); | |
} | |
else { | |
System.out.println("Param[] not null"); | |
params = Arrays.copyOf(params, params.length + 1); | |
params[params.length - 1] = new Params(); | |
params[params.length - 1].setKey(key); | |
params[params.length - 1].setValue(param); | |
} | |
} | |
public void removeParam (int key) { | |
boolean contain = false; | |
Params temp = null; | |
if(params != null) { | |
ArrayList<Params> list = new ArrayList<Params>(Arrays.asList(params)); | |
Iterator it = list.iterator(); | |
while(it.hasNext()){ | |
temp = (Params) it.next(); | |
if(temp.getKey() == key) { | |
contain = true; | |
break; | |
} | |
} | |
if(contain) { | |
list.remove(temp); | |
params = list.toArray(new Params[list.size()]); | |
} | |
} | |
} | |
public Params[] getParams () { | |
return params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment