Skip to content

Commit

Permalink
refactoring with code
Browse files Browse the repository at this point in the history
  • Loading branch information
gyc567 committed Jul 18, 2016
1 parent c7c5a63 commit 6d76f07
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/main/java/com/github/eric/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ public class Function {
private List args;
private int reslut;

public List getArgs() {
return args;
}

public void setArgs(List args) {
this.args = args;
}

public Operator getOperator() {
return operator;
}
Expand All @@ -33,16 +41,34 @@ public Function transform(ValuePair valuePair)
if(valuePair.first==null)
return null;

Object first = valuePair.first;
Object first = ValuePairUtils.first(valuePair);
Object rest = ValuePairUtils.rest(valuePair);
Function function=new Function();
if(first instanceof String)
{
if(((String) first).equalsIgnoreCase("+"))
{
Function function=new Function();

function.setOperator(Operator.PLUS);
}
}else if(rest instanceof ValuePair)
{
ValuePair vp= (ValuePair) rest;
function=travleValuePair(function,vp);
}
return null;
return function;
}

private Function travleValuePair(Function function, ValuePair vp) {
if (vp==null||vp.first==null)
return function;

Object first = vp.first;
function.getArgs().add(first);
if(vp.rest
!=null)
function.getArgs().add(vp.rest);
return function;
}

}

0 comments on commit 6d76f07

Please sign in to comment.