Skip to content

Commit

Permalink
Fix CB issues
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed May 5, 2015
1 parent 4e32fef commit bc885bb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
Expand Up @@ -19,14 +19,14 @@
import com.speedment.codegen.base.Generator; import com.speedment.codegen.base.Generator;
import com.speedment.codegen.base.Transform; import com.speedment.codegen.base.Transform;
import com.speedment.orm.field.StandardBinaryOperator; import com.speedment.orm.field.StandardBinaryOperator;
import com.speedment.orm.field.reference.BinaryPredicateBuilder; import com.speedment.orm.field.reference.ReferenceBinaryPredicateBuilder;
import java.util.Optional; import java.util.Optional;


/** /**
* *
* @author Emil Forslund * @author Emil Forslund
*/ */
public class BinaryPredicateBuilderView implements Transform<BinaryPredicateBuilder, String> { public class BinaryPredicateBuilderView implements Transform<ReferenceBinaryPredicateBuilder, String> {


private String render(StandardBinaryOperator op) { private String render(StandardBinaryOperator op) {
switch (op) { switch (op) {
Expand All @@ -43,7 +43,7 @@ private String render(StandardBinaryOperator op) {
} }


@Override @Override
public Optional<String> transform(Generator gen, BinaryPredicateBuilder model) { public Optional<String> transform(Generator gen, ReferenceBinaryPredicateBuilder model) {
return Optional.of( return Optional.of(
model.getField().getColumn().getName() + model.getField().getColumn().getName() +
render(model.getOperator()) + render(model.getOperator()) +
Expand Down
Expand Up @@ -17,18 +17,18 @@
package com.speedment.orm.core.manager.sql.generator; package com.speedment.orm.core.manager.sql.generator;


import com.speedment.codegen.base.DefaultTransformFactory; import com.speedment.codegen.base.DefaultTransformFactory;
import com.speedment.orm.field.reference.BinaryPredicateBuilder; import com.speedment.orm.field.reference.ReferenceBinaryPredicateBuilder;
import com.speedment.orm.field.reference.UnaryPredicateBuilder; import com.speedment.orm.field.reference.ReferenceUnaryPredicateBuilder;


/** /**
* *
* @author Emil Forslund * @author Emil Forslund
*/ */
public class SQLTransformFactory extends DefaultTransformFactory { public class SQLTransformFactory extends DefaultTransformFactory {


public SQLTransformFactory() { public SQLTransformFactory() {
super (SQLTransformFactory.class.getSimpleName()); super(SQLTransformFactory.class.getSimpleName());
install(UnaryPredicateBuilder.class, UnaryPredicateBuilderView.class); install(ReferenceUnaryPredicateBuilder.class, UnaryPredicateBuilderView.class);
install(BinaryPredicateBuilder.class, BinaryPredicateBuilderView.class); install(ReferenceBinaryPredicateBuilder.class, BinaryPredicateBuilderView.class);
} }
} }
Expand Up @@ -21,30 +21,34 @@
import com.speedment.orm.field.StandardUnaryOperator; import com.speedment.orm.field.StandardUnaryOperator;
import static com.speedment.orm.field.StandardUnaryOperator.IS_NOT_NULL; import static com.speedment.orm.field.StandardUnaryOperator.IS_NOT_NULL;
import static com.speedment.orm.field.StandardUnaryOperator.IS_NULL; import static com.speedment.orm.field.StandardUnaryOperator.IS_NULL;
import com.speedment.orm.field.reference.UnaryPredicateBuilder; import com.speedment.orm.field.reference.ReferenceUnaryPredicateBuilder;

import java.util.Optional; import java.util.Optional;


/** /**
* *
* @author Emil Forslund * @author Emil Forslund
*/ */
public class UnaryPredicateBuilderView implements Transform<UnaryPredicateBuilder, String> { public class UnaryPredicateBuilderView implements Transform<ReferenceUnaryPredicateBuilder, String> {

private String render(StandardUnaryOperator op) {
switch (op) {
case IS_NOT_NULL:
return " <> NULL";
case IS_NULL:
return " == NULL";
default:
throw new UnsupportedOperationException(
"Unknown enum constant " + op.name() + "."
);
}
}


private String render(StandardUnaryOperator op) { @Override
switch (op) { public Optional<String> transform(Generator gen, ReferenceUnaryPredicateBuilder model) {
case IS_NOT_NULL : return " <> NULL"; return Optional.of(
case IS_NULL : return " == NULL"; model.getField().getColumn().getName()
default : throw new UnsupportedOperationException( + render(model.getOperator())
"Unknown enum constant " + op.name() + "." );
); }
} }
}

@Override
public Optional<String> transform(Generator gen, UnaryPredicateBuilder model) {
return Optional.of(
model.getField().getColumn().getName() +
render(model.getOperator())
);
}
}

0 comments on commit bc885bb

Please sign in to comment.