Example usage for org.springframework.expression TypedValue TypedValue

List of usage examples for org.springframework.expression TypedValue TypedValue

Introduction

In this page you can find the example usage for org.springframework.expression TypedValue TypedValue.

Prototype

public TypedValue(@Nullable Object value) 

Source Link

Document

Create a TypedValue for a simple object.

Usage

From source file:com.joyveb.dbpimpl.cass.prepare.convert.RowReaderPropertyAccessor.java

public TypedValue read(EvaluationContext context, Object target, String name) {
    Row row = (Row) target;//from   w ww  .j av  a2 s  .c  om
    if (row.isNull(name)) {
        return TypedValue.NULL;
    }
    DataType columnType = row.getColumnDefinitions().getType(name);
    ByteBuffer bytes = row.getBytes(name);
    Object object = columnType.deserialize(bytes);
    return new TypedValue(object);
}

From source file:org.jasig.portlet.spring.DefaultPropertyAccessor.java

@Override
public TypedValue read(EvaluationContext evaluationContext, Object o, String s) throws AccessException {
    logger.error("Property '" + s + "' not found!");
    return new TypedValue(leading + s + trailing);
}

From source file:it.geosolutions.geostore.core.security.UserDetailsExpressionUserMapper.java

public UserDetailsExpressionUserMapper(Map<String, String> attributeMappings) {
    super(attributeMappings);

    // property accessor for UserDetailsWithAttributes attributes (read only)
    evaluationContext.addPropertyAccessor(new PropertyAccessor() {

        @Override//from   w ww  . j a  v a  2s.co m
        public void write(EvaluationContext ctx, Object target, String name, Object value)
                throws AccessException {

        }

        @Override
        public TypedValue read(EvaluationContext ctx, Object target, String name) throws AccessException {
            if (target instanceof UserDetailsWithAttributes) {
                UserDetailsWithAttributes details = (UserDetailsWithAttributes) target;
                return new TypedValue(details.getAttribute(name));
            }
            return null;
        }

        @Override
        public Class[] getSpecificTargetClasses() {
            return new Class[] { UserDetailsWithAttributes.class };
        }

        @Override
        public boolean canWrite(EvaluationContext ctx, Object target, String name) throws AccessException {
            return false;
        }

        @Override
        public boolean canRead(EvaluationContext ctx, Object target, String name) throws AccessException {
            return target instanceof UserDetailsWithAttributes;
        }
    });
}

From source file:guru.qas.martini.tag.ResourceExecutor.java

public TypedValue execute(Martini martini, String locationPattern) {
    URI martiniURI = getResource(martini);
    boolean evaluation = false;
    if (null != martiniURI) {
        List<Resource> resources = getResources(locationPattern);
        evaluation = resources.stream().map(ResourceExecutor::getURI).anyMatch(martiniURI::equals);
    }/*from  w  ww  .  j a va2s.c o m*/

    return new TypedValue(evaluation);
}

From source file:io.twipple.springframework.data.clusterpoint.convert.ClusterpointDocumentPropertyAccessor.java

/**
 * Read the value from the property.//from  ww w .  j a  v a 2s.  com
 *
 * @param context the evaluation context.
 * @param target  the target object.
 * @param name    the name of the property.
 * @return the typed value of the content to be read.
 */
@Override
public TypedValue read(@NotNull EvaluationContext context, @NotNull Object target, @NotNull String name) {

    Assert.notNull(context);
    Assert.notNull(target);
    Assert.isInstanceOf(ClusterpointDocument.class, target);
    Assert.hasText(name);

    ClusterpointDocument source = (ClusterpointDocument) target;

    Object value = source.read(context, name);
    return value == null ? TypedValue.NULL : new TypedValue(value);
}

From source file:com.creactiviti.piper.core.task.SpelTaskEvaluator.java

private TypedValue systemProperty(EvaluationContext aContext, Object aTarget, Object... aArgs)
        throws AccessException {
    return new TypedValue(System.getProperty((String) aArgs[0]));
}

From source file:com.creactiviti.piper.core.task.SpelTaskEvaluator.java

private MethodExecutor range() {
    return (ctx, target, args) -> {
        List<Integer> value = IntStream.rangeClosed((int) args[0], (int) args[1]).boxed()
                .collect(Collectors.toList());
        return new TypedValue(value);
    };//from   w ww . j  a  v  a 2s.  com
}

From source file:com.creactiviti.piper.core.task.SpelTaskEvaluator.java

private <T> MethodExecutor cast(Class<T> type) {
    return (ctx, target, args) -> {
        T value = type.cast(ConvertUtils.convert(args[0], type));
        return new TypedValue(value);
    };/* w ww .j ava2s  .c om*/
}

From source file:com.creactiviti.piper.core.task.SpelTaskEvaluator.java

private <T> MethodExecutor join() {
    return (ctx, target, args) -> {
        String separator = (String) args[0];
        List<T> values = (List<T>) args[1];
        String str = values.stream().map(String::valueOf).collect(Collectors.joining(separator));
        return new TypedValue(str);
    };// ww w . jav a  2 s  .  co  m
}

From source file:com.creactiviti.piper.core.task.SpelTaskEvaluator.java

private <T> MethodExecutor concat() {
    return (ctx, target, args) -> {
        List<T> l1 = (List<T>) args[0];
        List<T> l2 = (List<T>) args[1];
        List<T> joined = new ArrayList<T>(l1.size() + l2.size());
        joined.addAll(l1);// w  ww  . j av  a2  s .  co  m
        joined.addAll(l2);
        return new TypedValue(joined);
    };
}