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
@XmlRootElement | |
@Document(collection = "user") | |
@PersistenceCapable | |
@View | |
public class User { | |
@Id | |
@JsonIgnore(true) | |
private String id; | |
private String username; |
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
private String streamToString(InputStream is) throws IOException | |
{ | |
final char[] buffer = new char[0x10000]; | |
final StringBuilder out = new StringBuilder(); | |
InputStreamReader in = null; | |
try { | |
in = new InputStreamReader(is); | |
int read; | |
while((read = in.read(buffer)) > 0) { | |
out.append(buffer, 0, read); |
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
Document doc = document( | |
keys("comments"), | |
values(asList( | |
document(keys("content", "date"), values("test1", date("14/01/2011"))), | |
document(keys("content", "date"), values("test2", date("12/01/2011")))))); | |
Of cource it was refactored to: | |
private Document comment(final String content, final String dateStr) { | |
return document(keys("content", "date"), values(content, date(dateStr))); | |
} |
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
public Record addParserResult() { | |
Record record = new RecordImpl(); | |
record.clear(); | |
((RecordImpl) record) | |
.setRecordsReceived(((RecordImpl) record) | |
.getRecordsReceived() + this.getRecordsReceived()); | |
((RecordImpl) record).setRecordsWritten(((RecordImpl) record) | |
.getRecordsWritten() + this.getRecordsWritten()); | |
((RecordImpl) record) | |
.setHeardChangeMessage(((RecordImpl) record) |
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
using System; | |
namespace CodeAsData | |
{ | |
public class Pair | |
{ | |
static void Main(string[] args) | |
{ | |
var pair = create(1, 'a'); | |
Console.WriteLine(key(pair) + ":" + value(pair)); |