com.github.rauberprojects.client.transclude.DefaultTranscluder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of client-core Show documentation
Show all versions of client-core Show documentation
Reusable core classes for any client implementation.
package com.github.rauberprojects.client.transclude;
import com.github.rauberprojects.client.context.Context;
import com.github.rauberprojects.client.model.Data;
import com.github.rauberprojects.client.transclude.Transcluder;
import java.util.List;
/**
* A transcluder that works according to the specification by checking the transclude value of the data element.
*
* Implementation note:
* {@link Boolean#parseBoolean(String)} checks for null values and defaults to false if null is provided.
* This behaviour is in-line with the specification.
*/
public class DefaultTranscluder implements Transcluder {
@Override
public Context transclude(Data data, Context oldContext, Context newContext) {
final String transcludeValue = data.getTransclude();
boolean shouldTransclude = Boolean.parseBoolean(transcludeValue);
if (shouldTransclude) {
final List newData = newContext.getUber().getData();
data.setData(newData);
return oldContext;
} else {
return newContext;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy