* An optional local Sone that is used for Sone-specific data,
* such as if the Sone is followed by the local Sone
* @return The simple field set containing the given Sone
*/
protected static SimpleFieldSet encodeSone(Sone sone, String prefix, Optional<Sone> localSone) {
SimpleFieldSetBuilder soneBuilder = new SimpleFieldSetBuilder();
soneBuilder.put(prefix + "Name", sone.getName());
soneBuilder.put(prefix + "NiceName", SoneAccessor.getNiceName(sone));
soneBuilder.put(prefix + "LastUpdated", sone.getTime());
if (localSone.isPresent()) {
soneBuilder.put(prefix + "Followed", String.valueOf(localSone.get().hasFriend(sone.getId())));
}
Profile profile = sone.getProfile();
soneBuilder.put(prefix + "Field.Count", profile.getFields().size());
int fieldIndex = 0;
for (Field field : profile.getFields()) {
soneBuilder.put(prefix + "Field." + fieldIndex + ".Name", field.getName());
soneBuilder.put(prefix + "Field." + fieldIndex + ".Value", field.getValue());
++fieldIndex;
}
return soneBuilder.get();
}