forked from lightblue-platform/lightblue-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix lightblue-platform#120: Add literal class instead of literalRvalue
- Loading branch information
Burak Serdar
committed
May 27, 2015
1 parent
3e830db
commit 9c5dd5f
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
core/src/main/java/com/redhat/lightblue/client/expression/update/Literal.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.redhat.lightblue.client.expression.update; | ||
|
||
public class Literal implements RValue { | ||
private final Object value; | ||
|
||
public Literal(String value) { | ||
this.value = value; | ||
} | ||
|
||
public Literal(int value) { | ||
this.value = new Integer(value); | ||
} | ||
|
||
public Literal(double value) { | ||
this.value = new Double(value); | ||
} | ||
|
||
public Literal(float value) { | ||
this.value = new Float(value); | ||
} | ||
|
||
public Literal(long value) { | ||
this.value = new Long(value); | ||
} | ||
|
||
public Literal(Object value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toJson() { | ||
if(value==null) | ||
return null; | ||
else if(value instanceof String) | ||
return "\""+value+"\""; | ||
else | ||
return value.toString(); | ||
} | ||
} |
This file contains 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