public static EffectorSummary effectorSummary( final Entity entity, Effector<?> effector, UriBuilder ub) { URI applicationUri = serviceUriBuilder(ub, ApplicationApi.class, "get").build(entity.getApplicationId()); URI entityUri = serviceUriBuilder(ub, EntityApi.class, "get") .build(entity.getApplicationId(), entity.getId()); URI selfUri = serviceUriBuilder(ub, EffectorApi.class, "invoke") .build(entity.getApplicationId(), entity.getId(), effector.getName()); return new EffectorSummary( effector.getName(), effector.getReturnTypeName(), ImmutableSet.copyOf( Iterables.transform( effector.getParameters(), new Function<ParameterType<?>, EffectorSummary.ParameterSummary<?>>() { @Override public EffectorSummary.ParameterSummary<?> apply( @Nullable ParameterType<?> parameterType) { return parameterSummary(entity, parameterType); } })), effector.getDescription(), ImmutableMap.of( "self", selfUri, "entity", entityUri, "application", applicationUri)); }
public static EffectorSummary effectorSummaryForCatalog(Effector<?> effector) { Set<EffectorSummary.ParameterSummary<?>> parameters = ImmutableSet.copyOf( Iterables.transform( effector.getParameters(), new Function<ParameterType<?>, EffectorSummary.ParameterSummary<?>>() { @Override public EffectorSummary.ParameterSummary<?> apply(ParameterType<?> parameterType) { return parameterSummary(null, parameterType); } })); return new EffectorSummary( effector.getName(), effector.getReturnTypeName(), parameters, effector.getDescription(), null); }