Skip to content

Commit

Permalink
codegen: Minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyknic committed Feb 16, 2017
1 parent ff839fd commit 10c8c73
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
Expand Up @@ -83,7 +83,11 @@ public interface Generator {
* *
* @see Meta * @see Meta
*/ */
default <A, B> Stream<Meta<A, B>> metaOn(A from, Class<B> to, Class<? extends Transform<A, B>> transform) { default <A, B> Stream<Meta<A, B>> metaOn(
A from,
Class<B> to,
Class<? extends Transform<A, B>> transform) {

return metaOn(from, to) return metaOn(from, to)
.filter(meta -> transform.equals(meta.getTransform().getClass())); .filter(meta -> transform.equals(meta.getTransform().getClass()));
} }
Expand Down Expand Up @@ -113,7 +117,7 @@ default <M> Stream<Meta<M, String>> metaOn(M model) {
* @see Meta * @see Meta
*/ */
default <A> Stream<Meta<A, String>> metaOn(Collection<A> models) { default <A> Stream<Meta<A, String>> metaOn(Collection<A> models) {
return models.stream().map(this::metaOn).flatMap(m -> m); return models.stream().flatMap(this::metaOn);
} }


/** /**
Expand All @@ -128,8 +132,10 @@ default <A> Stream<Meta<A, String>> metaOn(Collection<A> models) {
* *
* @see Meta * @see Meta
*/ */
default <A, B> Stream<Meta<A, B>> metaOn(Collection<A> models, Class<B> to) { default <A, B> Stream<Meta<A, B>> metaOn(
return models.stream().map(model -> metaOn(model, to)).flatMap(m -> m); Collection<A> models, Class<B> to) {

return models.stream().flatMap(model -> metaOn(model, to));
} }


/** /**
Expand All @@ -149,7 +155,11 @@ default <A, B> Stream<Meta<A, B>> metaOn(Collection<A> models, Class<B> to) {
* *
* @see Meta * @see Meta
*/ */
default <A, B> Stream<Meta<A, B>> metaOn(Collection<A> models, Class<B> to, Class<? extends Transform<A, B>> transform) { default <A, B> Stream<Meta<A, B>> metaOn(
Collection<A> models,
Class<B> to,
Class<? extends Transform<A, B>> transform) {

return metaOn(models, to) return metaOn(models, to)
.filter(meta -> meta.getTransform().is(transform)); .filter(meta -> meta.getTransform().is(transform));
} }
Expand All @@ -163,16 +173,20 @@ default <A, B> Stream<Meta<A, B>> metaOn(Collection<A> models, Class<B> to, Clas
* @return the generated text if any * @return the generated text if any
*/ */
default Optional<String> on(Object model) { default Optional<String> on(Object model) {
final Object m;

if (model instanceof Optional) { if (model instanceof Optional) {
final Optional<?> result = (Optional<?>) model; final Optional<?> result = (Optional<?>) model;
if (result.isPresent()) { if (result.isPresent()) {
model = result.get(); m = result.get();
} else { } else {
return Optional.empty(); return Optional.empty();
} }
} else {
m = model;
} }


return metaOn(model).map(Meta::getResult).findAny(); return metaOn(m).map(Meta::getResult).findAny();
} }


/** /**
Expand Down Expand Up @@ -200,5 +214,8 @@ default <M> Stream<String> onEach(Collection<M> models) {
* @see Transform * @see Transform
* @see TransformFactory * @see TransformFactory
*/ */
<A, B> Optional<Meta<A, B>> transform(Transform<A, B> transform, A model, TransformFactory factory); <A, B> Optional<Meta<A, B>> transform(
Transform<A, B> transform,
A model,
TransformFactory factory);
} }
Expand Up @@ -19,6 +19,7 @@
import com.speedment.common.codegen.Generator; import com.speedment.common.codegen.Generator;
import com.speedment.common.codegen.internal.model.InterfaceMethodImpl; import com.speedment.common.codegen.internal.model.InterfaceMethodImpl;
import com.speedment.common.codegen.model.Interface; import com.speedment.common.codegen.model.Interface;
import com.speedment.common.codegen.model.InterfaceMethod;
import com.speedment.common.codegen.model.Method; import com.speedment.common.codegen.model.Method;


/** /**
Expand All @@ -44,7 +45,7 @@ protected String renderSupertype(Generator gen, Interface model) {
} }


@Override @Override
public Object wrapMethod(Method method) { public InterfaceMethod wrapMethod(Method method) {
return new InterfaceMethodImpl(method); return new InterfaceMethodImpl(method);
} }


Expand Down
Expand Up @@ -24,7 +24,8 @@
* *
* @author Emil Forslund * @author Emil Forslund
*/ */
public final class InterfaceImpl extends ClassOrInterfaceImpl<Interface> implements Interface { public final class InterfaceImpl extends ClassOrInterfaceImpl<Interface>
implements Interface {


/** /**
* Initializes this interface using a name. * Initializes this interface using a name.
Expand Down

0 comments on commit 10c8c73

Please sign in to comment.