Created
October 23, 2019 21:54
-
-
Save msangel/4a9b4404b233a6ff57a4ca54db3bfc1f to your computer and use it in GitHub Desktop.
Data PropertyResolverAdapter
This file contains hidden or 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
package liqp; | |
import java.util.Map; | |
/** | |
* Provide alternative to :data | |
* Used in some liquid transformation also used as main data storage in data model of jekyll. | |
*/ | |
public interface DataAccessor { | |
Map<String, Object> getData(); | |
} |
This file contains hidden or 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
package liqp.filters.where; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import liqp.DataAccessor; | |
import liqp.LValue; | |
public class DataAccessorPropertyResolverAdapter extends LValue implements PropertyResolverAdapter { | |
@Override | |
public Object getItemProperty(ObjectMapper mapper, Object input, Object property) { | |
return ((DataAccessor) input).getData().get(asString(property)); | |
} | |
@Override | |
public boolean support(Object target) { | |
return target instanceof DataAccessor; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment