Groowt-all and fp.
This commit is contained in:
parent
afa29b83fc
commit
59badf96f6
@ -10,20 +10,8 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testImplementation libs.junit.jupiter.api
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion = JavaLanguageVersion.of(21)
|
languageVersion = JavaLanguageVersion.of(21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testing {
|
|
||||||
suites {
|
|
||||||
test {
|
|
||||||
useJUnitJupiter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
35
buildSrc/src/main/groovy/groowt/gradle/groowt-testing.gradle
Normal file
35
buildSrc/src/main/groovy/groowt/gradle/groowt-testing.gradle
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
//file:noinspection GrPackage
|
||||||
|
plugins {
|
||||||
|
id 'groowt-conventions'
|
||||||
|
id 'groowt-logging'
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
testing {
|
||||||
|
canBeConsumed = false
|
||||||
|
canBeResolved = false
|
||||||
|
}
|
||||||
|
testImplementation {
|
||||||
|
extendsFrom configurations.testing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testing libs.junit.jupiter.api
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
testLogging.showStandardStreams = true
|
||||||
|
}
|
||||||
|
|
||||||
|
testing {
|
||||||
|
suites {
|
||||||
|
test {
|
||||||
|
useJUnitJupiter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
groowt-all/build.gradle
Normal file
22
groowt-all/build.gradle
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
plugins {
|
||||||
|
id 'groowt-conventions'
|
||||||
|
id 'groowt-publish'
|
||||||
|
id 'java-library'
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api project(':views')
|
||||||
|
api project(':view-components')
|
||||||
|
api project(':web-views')
|
||||||
|
api project(':di')
|
||||||
|
api project(':extensible')
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create('groowtAll', MavenPublication) {
|
||||||
|
artifactId = 'groowt-all'
|
||||||
|
from components.java
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@ pluginManagement {
|
|||||||
|
|
||||||
rootProject.name = 'groowt'
|
rootProject.name = 'groowt'
|
||||||
|
|
||||||
include 'cli', 'groowt-gradle', 'groowt-gradle-model', 'views', 'view-components', 'web-views'
|
include 'cli', 'groowt-all', 'groowt-gradle', 'groowt-gradle-model', 'views', 'view-components', 'web-views'
|
||||||
|
|
||||||
file('util').eachDir {
|
file('util').eachDir {
|
||||||
include it.name
|
include it.name
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'groowt-conventions'
|
id 'groowt-conventions'
|
||||||
|
id 'groowt-testing'
|
||||||
|
id 'groowt-logging'
|
||||||
|
id 'groowt-publish'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8,3 +11,16 @@ dependencies {
|
|||||||
compileOnlyApi libs.jetbrains.anotations
|
compileOnlyApi libs.jetbrains.anotations
|
||||||
implementation libs.slf4j.api, libs.groovy
|
implementation libs.slf4j.api, libs.groovy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
archiveBaseName = 'groowt-util-di'
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create('di', MavenPublication) {
|
||||||
|
artifactId = 'groowt-util-di'
|
||||||
|
from components.java
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,8 +1,21 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'groowt-conventions'
|
id 'groowt-conventions'
|
||||||
|
id 'groowt-publish'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnlyApi libs.jetbrains.anotations
|
compileOnlyApi libs.jetbrains.anotations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
archiveBaseName = 'groowt-util-extensible'
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create('extensible', MavenPublication) {
|
||||||
|
artifactId = 'groowt-util-extensible'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
26
util/fp/build.gradle
Normal file
26
util/fp/build.gradle
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
plugins {
|
||||||
|
id 'groowt-conventions'
|
||||||
|
id 'groowt-publish'
|
||||||
|
id 'java-library'
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnlyApi libs.jetbrains.anotations
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
archiveBaseName = 'groowt-util-fp'
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create('fp', MavenPublication) {
|
||||||
|
artifactId = 'groowt-util-fp'
|
||||||
|
from components.java
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package groowt.view.web.util;
|
package groowt.util.fp.either;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
23
util/fp/src/main/java/groowt/util/fp/hkt/Monoid.java
Normal file
23
util/fp/src/main/java/groowt/util/fp/hkt/Monoid.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package groowt.util.fp.hkt;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public final class Monoid<T> {
|
||||||
|
|
||||||
|
private final SemiGroup<T> semiGroup;
|
||||||
|
private final Zero<T> zero;
|
||||||
|
|
||||||
|
public Monoid(SemiGroup<T> semiGroup, Zero<T> zero) {
|
||||||
|
this.semiGroup = Objects.requireNonNull(semiGroup);
|
||||||
|
this.zero = Objects.requireNonNull(zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T concat(T left, T right) {
|
||||||
|
return this.semiGroup.concat(left, right);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T empty() {
|
||||||
|
return this.zero.getEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,13 +1,17 @@
|
|||||||
package groowt.view.web.util;
|
package groowt.util.fp.hkt;
|
||||||
|
|
||||||
import java.util.function.BinaryOperator;
|
import java.util.function.BinaryOperator;
|
||||||
|
|
||||||
public final class SemiGroup<T> {
|
public final class SemiGroup<T> {
|
||||||
|
|
||||||
private final BinaryOperator<T> concat;
|
private final BinaryOperator<T> concat;
|
||||||
|
|
||||||
public SemiGroup(BinaryOperator<T> concat) {
|
public SemiGroup(BinaryOperator<T> concat) {
|
||||||
this.concat = concat;
|
this.concat = concat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T concat(T left, T right) {
|
public T concat(T left, T right) {
|
||||||
return this.concat.apply(left, right);
|
return this.concat.apply(left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
17
util/fp/src/main/java/groowt/util/fp/hkt/Zero.java
Normal file
17
util/fp/src/main/java/groowt/util/fp/hkt/Zero.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package groowt.util.fp.hkt;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public final class Zero<T> {
|
||||||
|
|
||||||
|
private final T empty;
|
||||||
|
|
||||||
|
public Zero(T empty) {
|
||||||
|
this.empty = Objects.requireNonNull(empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getEmpty() {
|
||||||
|
return this.empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package groowt.view.web.util;
|
package groowt.util.fp.option;
|
||||||
|
|
||||||
|
import groowt.util.fp.hkt.Monoid;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
56
util/fp/src/main/java/groowt/util/fp/property/Property.java
Normal file
56
util/fp/src/main/java/groowt/util/fp/property/Property.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package groowt.util.fp.property;
|
||||||
|
|
||||||
|
import groowt.util.fp.provider.Provider;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public interface Property<T> extends Provider<T> {
|
||||||
|
|
||||||
|
static <T> Property<T> get(Class<? extends T> tClass) {
|
||||||
|
return new SimpleProperty<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T> Property<T> of(T t) {
|
||||||
|
final Property<T> property = new SimpleProperty<>();
|
||||||
|
property.set(t);
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T> Property<T> ofLazy(Provider<T> tProvider) {
|
||||||
|
final Property<T> property = new SimpleProperty<>();
|
||||||
|
property.set(tProvider);
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T> Property<T> ofLazy(Supplier<T> tSupplier) {
|
||||||
|
final Property<T> property = new SimpleProperty<>();
|
||||||
|
property.set(Provider.ofLazy(tSupplier));
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(T t);
|
||||||
|
void set(Provider<? extends T> tProvider);
|
||||||
|
void setConvention(T t);
|
||||||
|
void setConvention(Provider<? extends T> tProvider);
|
||||||
|
|
||||||
|
boolean isPresent();
|
||||||
|
boolean isEmpty();
|
||||||
|
|
||||||
|
default T fold(@Nullable T onEmpty) {
|
||||||
|
if (this.isPresent()) {
|
||||||
|
return this.get();
|
||||||
|
} else {
|
||||||
|
return onEmpty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
default T fold(Provider<? extends T> onEmpty) {
|
||||||
|
if (this.isPresent()) {
|
||||||
|
return this.get();
|
||||||
|
} else {
|
||||||
|
return onEmpty.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package groowt.util.fp.property;
|
||||||
|
|
||||||
|
import groowt.util.fp.provider.Provider;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
final class SimpleProperty<T> implements Property<T> {
|
||||||
|
|
||||||
|
private Provider<? extends T> provider;
|
||||||
|
private Provider<? extends T> convention;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPresent() {
|
||||||
|
return this.provider != null || this.convention != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return this.provider == null && this.convention == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(T t) {
|
||||||
|
Objects.requireNonNull(t);
|
||||||
|
this.provider = Provider.of(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(Provider<? extends T> tProvider) {
|
||||||
|
Objects.requireNonNull(tProvider);
|
||||||
|
this.provider = tProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setConvention(T convention) {
|
||||||
|
Objects.requireNonNull(convention);
|
||||||
|
this.convention = Provider.of(convention);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setConvention(Provider<? extends T> convention) {
|
||||||
|
Objects.requireNonNull(convention);
|
||||||
|
this.convention = convention;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T get() {
|
||||||
|
if (!this.isPresent()) {
|
||||||
|
throw new NullPointerException("Cannot get() from an empty Property. Set the value or set the convention.");
|
||||||
|
} else if (this.provider != null) {
|
||||||
|
return this.provider.get();
|
||||||
|
} else {
|
||||||
|
return this.convention.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package groowt.util.fp.provider;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
final class LazyProvider<T> implements Provider<T> {
|
||||||
|
|
||||||
|
private final Supplier<? extends T> lazy;
|
||||||
|
|
||||||
|
public LazyProvider(Supplier<? extends T> supplier) {
|
||||||
|
this.lazy = supplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T get() {
|
||||||
|
return this.lazy.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
26
util/fp/src/main/java/groowt/util/fp/provider/Provider.java
Normal file
26
util/fp/src/main/java/groowt/util/fp/provider/Provider.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package groowt.util.fp.provider;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public interface Provider<T> {
|
||||||
|
|
||||||
|
static <T> Provider<T> of(T t) {
|
||||||
|
return new SimpleProvider<>(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
static <T> Provider<T> ofLazy(Supplier<? extends T> tSupplier) {
|
||||||
|
return new LazyProvider<>(tSupplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
T get();
|
||||||
|
|
||||||
|
default <U> Provider<U> map(Function<? super T, ? extends U> mapper) {
|
||||||
|
return new LazyProvider<>(() -> mapper.apply(this.get()));
|
||||||
|
}
|
||||||
|
|
||||||
|
default <U> Provider<U> flatMap(Function<? super T, ? extends Provider<? extends U>> flatMapper) {
|
||||||
|
return new LazyProvider<>(() -> flatMapper.apply(this.get()).get());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,18 +1,17 @@
|
|||||||
package groowt.view.web.util;
|
package groowt.util.fp.provider;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
final class SimpleProvider<T> implements Provider<T> {
|
final class SimpleProvider<T> implements Provider<T> {
|
||||||
|
|
||||||
private final T t;
|
private final T t;
|
||||||
|
|
||||||
public SimpleProvider(T t) {
|
public SimpleProvider(T t) {
|
||||||
this.t = t;
|
this.t = Objects.requireNonNull(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get() {
|
public T get() {
|
||||||
if (this.t == null) {
|
|
||||||
throw new NullPointerException("This Provider has a null value.");
|
|
||||||
}
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'groowt-conventions'
|
||||||
|
id 'groowt-testing'
|
||||||
|
id 'groowt-publish'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
id 'groovy'
|
id 'groovy'
|
||||||
}
|
}
|
||||||
@ -9,27 +11,17 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api libs.groovy, libs.groovy.templates, libs.jetbrains.anotations, project(':views')
|
api libs.groovy
|
||||||
|
api libs.jetbrains.anotations
|
||||||
|
api project(':views')
|
||||||
|
|
||||||
implementation libs.slf4j.api
|
implementation libs.slf4j.api
|
||||||
|
|
||||||
testImplementation libs.junit.jupiter.api
|
|
||||||
testRuntimeOnly libs.log4j.slf4jBinding, libs.log4j.core
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
publishing {
|
||||||
toolchain {
|
publications {
|
||||||
languageVersion = JavaLanguageVersion.of(21)
|
create('viewComponents', MavenPublication) {
|
||||||
}
|
artifactId = 'groowt-view-components'
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
testLogging.showStandardStreams = true
|
|
||||||
}
|
|
||||||
|
|
||||||
testing {
|
|
||||||
suites {
|
|
||||||
test {
|
|
||||||
useJUnitJupiter()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'groowt-conventions'
|
||||||
|
id 'groowt-testing'
|
||||||
|
id 'groowt-publish'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
id 'groovy'
|
id 'groovy'
|
||||||
}
|
}
|
||||||
@ -9,27 +11,21 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api libs.groovy, libs.groovy.templates
|
api libs.groovy
|
||||||
|
api libs.groovy.templates
|
||||||
|
|
||||||
implementation libs.slf4j.api
|
implementation libs.slf4j.api
|
||||||
|
|
||||||
testImplementation libs.junit.jupiter.api
|
|
||||||
testRuntimeOnly libs.log4j.slf4jBinding, libs.log4j.core
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
toolchain {
|
|
||||||
languageVersion = JavaLanguageVersion.of(21)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
testLogging.showStandardStreams = true
|
testLogging.showStandardStreams = true
|
||||||
}
|
}
|
||||||
|
|
||||||
testing {
|
publishing {
|
||||||
suites {
|
publications {
|
||||||
test {
|
create('views', MavenPublication) {
|
||||||
useJUnitJupiter()
|
artifactId = 'groowt-views'
|
||||||
|
from components.java
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ import groowt.gradle.antlr.GroowtAntlrExecTask
|
|||||||
plugins {
|
plugins {
|
||||||
id 'groowt-conventions'
|
id 'groowt-conventions'
|
||||||
id 'groowt-antlr-plugin'
|
id 'groowt-antlr-plugin'
|
||||||
id 'groowt-logging'
|
id 'groowt-testing'
|
||||||
|
id 'groowt-publish'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
id 'groovy'
|
id 'groovy'
|
||||||
id 'org.jetbrains.kotlin.jvm'
|
id 'org.jetbrains.kotlin.jvm'
|
||||||
@ -16,6 +17,9 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
|
testFixturesApi {
|
||||||
|
extendsFrom configurations.testing
|
||||||
|
}
|
||||||
groovyConsole
|
groovyConsole
|
||||||
toolsImplementation {
|
toolsImplementation {
|
||||||
extendsFrom(apiElements, runtimeElements)
|
extendsFrom(apiElements, runtimeElements)
|
||||||
@ -46,6 +50,7 @@ dependencies {
|
|||||||
libs.groovy,
|
libs.groovy,
|
||||||
libs.groovy.templates,
|
libs.groovy.templates,
|
||||||
libs.antlr.runtime,
|
libs.antlr.runtime,
|
||||||
|
project(':fp'),
|
||||||
project(':view-components'),
|
project(':view-components'),
|
||||||
project(':views')
|
project(':views')
|
||||||
)
|
)
|
||||||
@ -63,7 +68,7 @@ dependencies {
|
|||||||
runtimeOnly libs.log4j.slf4jBinding
|
runtimeOnly libs.log4j.slf4jBinding
|
||||||
|
|
||||||
def testLibs = [
|
def testLibs = [
|
||||||
libs.junit.jupiter.api, libs.mockito.core, libs.mockito.junit
|
libs.mockito.core, libs.mockito.junit
|
||||||
]
|
]
|
||||||
|
|
||||||
testLibs.each {
|
testLibs.each {
|
||||||
@ -188,13 +193,13 @@ tasks.register('cleanBin', Delete) {
|
|||||||
|
|
||||||
test {
|
test {
|
||||||
jvmArgs '-XX:+EnableDynamicAgentLoading' // for mockito/bytebuddy
|
jvmArgs '-XX:+EnableDynamicAgentLoading' // for mockito/bytebuddy
|
||||||
testLogging.showStandardStreams = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
testing {
|
publishing {
|
||||||
suites {
|
publications {
|
||||||
test {
|
create('webViews', MavenPublication) {
|
||||||
useJUnitJupiter()
|
artifactId = 'groowt-web-views'
|
||||||
|
from components.java
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package groowt.view.web.transpile;
|
package groowt.view.web.transpile;
|
||||||
|
|
||||||
|
import groowt.util.fp.provider.Provider;
|
||||||
import groowt.view.component.context.ComponentResolveException;
|
import groowt.view.component.context.ComponentResolveException;
|
||||||
import groowt.view.component.runtime.ComponentCreateException;
|
import groowt.view.component.runtime.ComponentCreateException;
|
||||||
import groowt.view.web.WebViewComponentBugError;
|
import groowt.view.web.WebViewComponentBugError;
|
||||||
@ -7,7 +8,6 @@ import groowt.view.web.ast.node.*;
|
|||||||
import groowt.view.web.transpile.groovy.GroovyUtil;
|
import groowt.view.web.transpile.groovy.GroovyUtil;
|
||||||
import groowt.view.web.transpile.groovy.GroovyUtil.ConvertResult;
|
import groowt.view.web.transpile.groovy.GroovyUtil.ConvertResult;
|
||||||
import groowt.view.web.transpile.resolve.ComponentClassNodeResolver;
|
import groowt.view.web.transpile.resolve.ComponentClassNodeResolver;
|
||||||
import groowt.view.web.util.Provider;
|
|
||||||
import groowt.view.web.util.SourcePosition;
|
import groowt.view.web.util.SourcePosition;
|
||||||
import org.codehaus.groovy.ast.*;
|
import org.codehaus.groovy.ast.*;
|
||||||
import org.codehaus.groovy.ast.expr.*;
|
import org.codehaus.groovy.ast.expr.*;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package groowt.view.web.transpile;
|
package groowt.view.web.transpile;
|
||||||
|
|
||||||
|
import groowt.util.fp.option.Option;
|
||||||
import groowt.view.web.antlr.MergedGroovyCodeToken;
|
import groowt.view.web.antlr.MergedGroovyCodeToken;
|
||||||
import groowt.view.web.antlr.WebViewComponentsLexer;
|
import groowt.view.web.antlr.WebViewComponentsLexer;
|
||||||
import groowt.view.web.ast.extension.GStringNodeExtension;
|
import groowt.view.web.ast.extension.GStringNodeExtension;
|
||||||
@ -10,7 +11,6 @@ import groowt.view.web.ast.node.JStringBodyTextNode;
|
|||||||
import groowt.view.web.ast.node.Node;
|
import groowt.view.web.ast.node.Node;
|
||||||
import groowt.view.web.transpile.groovy.GroovyUtil;
|
import groowt.view.web.transpile.groovy.GroovyUtil;
|
||||||
import groowt.view.web.util.FilteringIterable;
|
import groowt.view.web.util.FilteringIterable;
|
||||||
import groowt.view.web.util.Option;
|
|
||||||
import groowt.view.web.util.TokenRange;
|
import groowt.view.web.util.TokenRange;
|
||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
import org.codehaus.groovy.ast.expr.*;
|
import org.codehaus.groovy.ast.expr.*;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package groowt.view.web.transpile;
|
package groowt.view.web.transpile;
|
||||||
|
|
||||||
|
import groowt.util.fp.provider.Provider;
|
||||||
import groowt.view.web.transpile.resolve.ComponentClassNodeResolver;
|
import groowt.view.web.transpile.resolve.ComponentClassNodeResolver;
|
||||||
import groowt.view.web.util.Provider;
|
|
||||||
|
|
||||||
public class DefaultTranspilerConfiguration implements TranspilerConfiguration {
|
public class DefaultTranspilerConfiguration implements TranspilerConfiguration {
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package groowt.view.web.transpile.resolve;
|
package groowt.view.web.transpile.resolve;
|
||||||
|
|
||||||
|
import groowt.util.fp.either.Either;
|
||||||
import groowt.view.web.WebViewComponent;
|
import groowt.view.web.WebViewComponent;
|
||||||
import groowt.view.web.compiler.WebViewComponentTemplateCompileUnit;
|
import groowt.view.web.compiler.WebViewComponentTemplateCompileUnit;
|
||||||
import groowt.view.web.util.Either;
|
|
||||||
import org.codehaus.groovy.ast.ClassHelper;
|
import org.codehaus.groovy.ast.ClassHelper;
|
||||||
import org.codehaus.groovy.ast.ClassNode;
|
import org.codehaus.groovy.ast.ClassNode;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package groowt.view.web.transpile.resolve;
|
package groowt.view.web.transpile.resolve;
|
||||||
|
|
||||||
|
import groowt.util.fp.either.Either;
|
||||||
import groowt.view.web.compiler.WebViewComponentTemplateCompileUnit;
|
import groowt.view.web.compiler.WebViewComponentTemplateCompileUnit;
|
||||||
import groowt.view.web.util.Either;
|
|
||||||
import org.codehaus.groovy.ast.ClassNode;
|
import org.codehaus.groovy.ast.ClassNode;
|
||||||
import org.codehaus.groovy.ast.ModuleNode;
|
import org.codehaus.groovy.ast.ModuleNode;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package groowt.view.web.transpile.resolve;
|
package groowt.view.web.transpile.resolve;
|
||||||
|
|
||||||
|
import groowt.util.fp.either.Either;
|
||||||
import groowt.view.web.compiler.WebViewComponentTemplateCompileException;
|
import groowt.view.web.compiler.WebViewComponentTemplateCompileException;
|
||||||
import groowt.view.web.compiler.WebViewComponentTemplateCompileUnit;
|
import groowt.view.web.compiler.WebViewComponentTemplateCompileUnit;
|
||||||
import groowt.view.web.util.Either;
|
|
||||||
import org.codehaus.groovy.ast.ClassNode;
|
import org.codehaus.groovy.ast.ClassNode;
|
||||||
|
|
||||||
public interface ComponentClassNodeResolver {
|
public interface ComponentClassNodeResolver {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package groowt.view.web.transpile.resolve;
|
package groowt.view.web.transpile.resolve;
|
||||||
|
|
||||||
|
import groowt.util.fp.either.Either;
|
||||||
import groowt.view.web.compiler.WebViewComponentTemplateCompileUnit;
|
import groowt.view.web.compiler.WebViewComponentTemplateCompileUnit;
|
||||||
import groowt.view.web.util.Either;
|
|
||||||
import org.codehaus.groovy.ast.ClassNode;
|
import org.codehaus.groovy.ast.ClassNode;
|
||||||
import org.codehaus.groovy.ast.ModuleNode;
|
import org.codehaus.groovy.ast.ModuleNode;
|
||||||
|
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package groowt.view.web.util;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
final class LazyProvider<T> implements Provider<T> {
|
|
||||||
|
|
||||||
private final Provider<T> lazy;
|
|
||||||
|
|
||||||
public LazyProvider(Supplier<T> supplier) {
|
|
||||||
this.lazy = () -> {
|
|
||||||
final @Nullable T t = supplier.get();
|
|
||||||
if (t == null) {
|
|
||||||
throw new NullPointerException("This Provider has a null value.");
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T get() {
|
|
||||||
return this.lazy.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package groowt.view.web.util;
|
|
||||||
|
|
||||||
public final class Monoid<T> {
|
|
||||||
|
|
||||||
private final SemiGroup<T> semiGroup;
|
|
||||||
private final T empty;
|
|
||||||
|
|
||||||
public Monoid(SemiGroup<T> semiGroup, T empty) {
|
|
||||||
this.semiGroup = semiGroup;
|
|
||||||
this.empty = empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T concat(T left, T right) {
|
|
||||||
return this.semiGroup.concat(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public T empty() {
|
|
||||||
return this.empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package groowt.view.web.util;
|
|
||||||
|
|
||||||
public interface Property<T> extends Provider<T> {
|
|
||||||
void set(T t);
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package groowt.view.web.util;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public interface Provider<T> {
|
|
||||||
|
|
||||||
static <T> Provider<T> of(T t) {
|
|
||||||
return new SimpleProvider<>(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
static <T> Provider<T> ofLazy(Supplier<T> tSupplier) {
|
|
||||||
return new LazyProvider<>(tSupplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
T get();
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user