-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/38 builder for capabilities (#39)
* #38: Builder for Capabilities * #38: Updated launch configurations * #38: Removed superfluous JUnit4 dependency
- Loading branch information
1 parent
d9258fb
commit b0e184a
Showing
10 changed files
with
367 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig"> | ||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> | ||
<listEntry value="/virtual-schema-common-java"/> | ||
</listAttribute> | ||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> | ||
<listEntry value="4"/> | ||
</listAttribute> | ||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> | ||
<listEntry value="org.eclipse.eclemma.ui.launchGroup.coverage"/> | ||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> | ||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> | ||
</listAttribute> | ||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=virtual-schema-common-java"/> | ||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> | ||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> | ||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit5"/> | ||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/> | ||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="virtual-schema-common-java"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/> | ||
</launchConfiguration> |
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
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
202 changes: 137 additions & 65 deletions
202
src/main/java/com/exasol/adapter/capabilities/Capabilities.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 |
---|---|---|
@@ -1,91 +1,163 @@ | ||
package com.exasol.adapter.capabilities; | ||
|
||
import java.util.HashSet; | ||
import java.util.EnumSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* Manages a set of supported Capabilities | ||
* Manages a set of supported capabilities | ||
*/ | ||
public class Capabilities { | ||
private final Set<MainCapability> mainCapabilities = new HashSet<>(); | ||
private final Set<ScalarFunctionCapability> scalarFunctionCaps = new HashSet<>(); | ||
private final Set<PredicateCapability> predicateCaps = new HashSet<>(); | ||
private final Set<AggregateFunctionCapability> aggregateFunctionCaps = new HashSet<>(); | ||
private final Set<LiteralCapability> literalCaps = new HashSet<>(); | ||
|
||
public void supportAllCapabilities() { | ||
for (final MainCapability cap : MainCapability.values()) { | ||
supportMainCapability(cap); | ||
} | ||
for (final ScalarFunctionCapability function : ScalarFunctionCapability.values()) { | ||
supportScalarFunction(function); | ||
} | ||
for (final PredicateCapability pred : PredicateCapability.values()) { | ||
supportPredicate(pred); | ||
} | ||
for (final AggregateFunctionCapability function : AggregateFunctionCapability.values()) { | ||
supportAggregateFunction(function); | ||
} | ||
for (final LiteralCapability cap : LiteralCapability.values()) { | ||
supportLiteral(cap); | ||
} | ||
} | ||
private final Set<MainCapability> mainCapabilities; | ||
private final Set<LiteralCapability> literalCapabilities; | ||
private final Set<PredicateCapability> predicateCapabilities; | ||
private final Set<ScalarFunctionCapability> scalarFunctionCapabilities; | ||
private final Set<AggregateFunctionCapability> aggregateFunctionCapabilities; | ||
|
||
public void subtractCapabilities(final Capabilities capabilitiesToSubtract) { | ||
for (final MainCapability cap : capabilitiesToSubtract.mainCapabilities) { | ||
mainCapabilities.remove(cap); | ||
} | ||
for (final ScalarFunctionCapability cap : capabilitiesToSubtract.getScalarFunctionCapabilities()) { | ||
scalarFunctionCaps.remove(cap); | ||
} | ||
for (final PredicateCapability cap : capabilitiesToSubtract.getPredicateCapabilities()) { | ||
predicateCaps.remove(cap); | ||
} | ||
for (final AggregateFunctionCapability cap : capabilitiesToSubtract.getAggregateFunctionCapabilities()) { | ||
aggregateFunctionCaps.remove(cap); | ||
} | ||
for (final LiteralCapability cap : capabilitiesToSubtract.getLiteralCapabilities()) { | ||
literalCaps.remove(cap); | ||
} | ||
private Capabilities(final Builder builder) { | ||
this.mainCapabilities = EnumSet.copyOf(builder.mainCapabilities); | ||
this.literalCapabilities = EnumSet.copyOf(builder.literalCapabilities); | ||
this.predicateCapabilities = EnumSet.copyOf(builder.predicateCapabilities); | ||
this.scalarFunctionCapabilities = EnumSet.copyOf(builder.scalarFunctionCapabilities); | ||
this.aggregateFunctionCapabilities = EnumSet.copyOf(builder.aggregateFunctionCapabilities); | ||
} | ||
|
||
public void supportMainCapability(final MainCapability cap) { | ||
mainCapabilities.add(cap); | ||
/** | ||
* Get the Virtual Schema's adapters main capabilities | ||
* | ||
* @return main capabilities | ||
*/ | ||
public Set<MainCapability> getMainCapabilities() { | ||
return this.mainCapabilities; | ||
} | ||
|
||
public void supportScalarFunction(final ScalarFunctionCapability functionType) { | ||
scalarFunctionCaps.add(functionType); | ||
/** | ||
* Get the Virtual Schema's adapters literal capabilities | ||
* | ||
* @return scalar literal capabilities | ||
*/ | ||
public Set<LiteralCapability> getLiteralCapabilities() { | ||
return this.literalCapabilities; | ||
} | ||
|
||
public void supportPredicate(final PredicateCapability predicate) { | ||
predicateCaps.add(predicate); | ||
/** | ||
* Get the Virtual Schema's adapters predicate capabilities | ||
* | ||
* @return predicate capabilities | ||
*/ | ||
public Set<PredicateCapability> getPredicateCapabilities() { | ||
return this.predicateCapabilities; | ||
} | ||
|
||
public void supportAggregateFunction(final AggregateFunctionCapability functionType) { | ||
aggregateFunctionCaps.add(functionType); | ||
/** | ||
* Get the Virtual Schema's adapters scalar function capabilities | ||
* | ||
* @return scalar function capabilities | ||
*/ | ||
public Set<ScalarFunctionCapability> getScalarFunctionCapabilities() { | ||
return this.scalarFunctionCapabilities; | ||
} | ||
|
||
public void supportLiteral(final LiteralCapability literal) { | ||
literalCaps.add(literal); | ||
/** | ||
* Get the Virtual Schema's adapters aggregate function capabilities | ||
* | ||
* @return aggregate function capabilities | ||
*/ | ||
public Set<AggregateFunctionCapability> getAggregateFunctionCapabilities() { | ||
return this.aggregateFunctionCapabilities; | ||
} | ||
|
||
public Set<MainCapability> getMainCapabilities() { | ||
return mainCapabilities; | ||
/** | ||
* Get a {@link Capabilities} builder | ||
* | ||
* @return builder instance | ||
*/ | ||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public Set<ScalarFunctionCapability> getScalarFunctionCapabilities() { | ||
return scalarFunctionCaps; | ||
} | ||
/** | ||
* Builder for {@link Capabilities} | ||
*/ | ||
public static final class Builder { | ||
final Set<MainCapability> mainCapabilities = EnumSet.noneOf(MainCapability.class); | ||
final Set<LiteralCapability> literalCapabilities = EnumSet.noneOf(LiteralCapability.class); | ||
final Set<PredicateCapability> predicateCapabilities = EnumSet.noneOf(PredicateCapability.class); | ||
final Set<ScalarFunctionCapability> scalarFunctionCapabilities = EnumSet.noneOf(ScalarFunctionCapability.class); | ||
final Set<AggregateFunctionCapability> aggregateFunctionCapabilities = EnumSet | ||
.noneOf(AggregateFunctionCapability.class); | ||
|
||
public Set<PredicateCapability> getPredicateCapabilities() { | ||
return predicateCaps; | ||
} | ||
/** | ||
* Create new capability instance | ||
* | ||
* @return new capability instance | ||
*/ | ||
public Capabilities build() { | ||
return new Capabilities(this); | ||
} | ||
|
||
public Set<AggregateFunctionCapability> getAggregateFunctionCapabilities() { | ||
return aggregateFunctionCaps; | ||
} | ||
/** | ||
* Add one or more main capabilities | ||
* | ||
* @param capabilities capabilities to be added | ||
* @return builder instance for fluent programming | ||
*/ | ||
public Builder addMain(final MainCapability... capabilities) { | ||
for (final MainCapability capability : capabilities) { | ||
this.mainCapabilities.add(capability); | ||
} | ||
return this; | ||
} | ||
|
||
public Set<LiteralCapability> getLiteralCapabilities() { | ||
return literalCaps; | ||
/** | ||
* Add one or more literal capabilities | ||
* | ||
* @param capabilities capabilities to be added | ||
* @return builder instance for fluent programming | ||
*/ | ||
public Builder addLiteral(final LiteralCapability... capabilities) { | ||
for (final LiteralCapability capability : capabilities) { | ||
this.literalCapabilities.add(capability); | ||
} | ||
return this; | ||
} | ||
|
||
/** | ||
* Add one or more predicate capabilities | ||
* | ||
* @param capabilities capabilities to be added | ||
* @return builder instance for fluent programming | ||
*/ | ||
public Builder addPredicate(final PredicateCapability... capabilities) { | ||
for (final PredicateCapability capability : capabilities) { | ||
this.predicateCapabilities.add(capability); | ||
} | ||
return this; | ||
} | ||
|
||
/** | ||
* Add one or more scalar function capabilities | ||
* | ||
* @param capabilities capabilities to be added | ||
* @return builder instance for fluent programming | ||
*/ | ||
public Builder addScalarFunction(final ScalarFunctionCapability... capabilities) { | ||
for (final ScalarFunctionCapability capability : capabilities) { | ||
this.scalarFunctionCapabilities.add(capability); | ||
} | ||
return this; | ||
} | ||
|
||
/** | ||
* Add one or more aggregate function capabilities | ||
* | ||
* @param capabilities capabilities to be added | ||
* @return builder instance for fluent programming | ||
*/ | ||
public Builder addAggregateFunction(final AggregateFunctionCapability... capabilities) { | ||
for (final AggregateFunctionCapability capability : capabilities) { | ||
this.aggregateFunctionCapabilities.add(capability); | ||
} | ||
return this; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.