Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
930 additions
and
446 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
38 changes: 38 additions & 0 deletions
38
src/main/java/com/speedment/codegen/model/AbstractCodeModel.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.speedment.codegen.model; | ||
|
||
import java.util.function.BiConsumer; | ||
import java.util.function.Consumer; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* | ||
* @author pemi | ||
* @param <T> the CodeModel type | ||
*/ | ||
public abstract class AbstractCodeModel<T extends AbstractCodeModel<T>> implements CodeModel { | ||
|
||
@SuppressWarnings("unchecked") | ||
protected <P> T add(final P parameter, final Consumer<P> consumer) { | ||
consumer.accept(parameter); | ||
return (T) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
protected <P> T addSeveral(final P[] restOfParameters, final Consumer<P> consumer) { | ||
Stream.of(restOfParameters).forEach(consumer::accept); | ||
return (T) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
protected <P1, P2> T add(final P1 firstParameter, final P2 secondParameter, final BiConsumer<P1, P2> biConsumer) { | ||
biConsumer.accept(firstParameter, secondParameter); | ||
return (T) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
protected <P> T set(final P item, final Consumer<P> consumer) { | ||
consumer.accept(item); | ||
return (T) this; | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/speedment/codegen/model/AbstractModifiableCodeModel.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.speedment.codegen.model; | ||
|
||
import com.speedment.codegen.model.modifier.Modifiable; | ||
import com.speedment.codegen.model.modifier.Modifier_; | ||
import java.util.Set; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* | ||
* @author pemi | ||
* @param <T> | ||
* @param <M> | ||
*/ | ||
public abstract class AbstractModifiableCodeModel<T extends AbstractModifiableCodeModel<T, M>, M extends Modifier_<M>> extends AbstractCodeModel<T> implements Modifiable<M> { | ||
|
||
@Override | ||
public T add(final M firstClassModifier_m, final M... restClassModifiers) { | ||
return add(firstClassModifier_m, restClassModifiers, (f, s) -> { | ||
getModifiers().add(f); | ||
Stream.of(s).forEach(getModifiers()::add); | ||
}); | ||
} | ||
|
||
@Override | ||
public T set(final Set<M> newSet) { | ||
return set(newSet, s -> { | ||
getModifiers().clear(); | ||
getModifiers().addAll(s); | ||
}); | ||
} | ||
|
||
@Override | ||
public boolean is(M modifier) { | ||
return getModifiers().contains(modifier); | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.