Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #456 from dbluhm/fix-builds
Browse files Browse the repository at this point in the history
Fix builds, revert JavascriptValidator generics removal
  • Loading branch information
dbluhm committed Aug 7, 2020
2 parents 968357d + 487bb08 commit bac2200
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 44 deletions.
39 changes: 16 additions & 23 deletions org.eclipse.ice.build/pom.xml
@@ -1,31 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.ice</groupId>
<artifactId>org.eclipse.ice.parent</artifactId>
<version>2.2.1-SNAPSHOT</version>
<relativePath>../org.eclipse.ice.parent/pom.xml</relativePath>
</parent>
<groupId>org.eclipse.ice</groupId>
<artifactId>org.eclipse.ice.build</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<groupId>org.eclipse.ice</groupId>
<artifactId>org.eclipse.ice.build</artifactId>
<version>3.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>org.eclipse.ice.build</name>
<name>org.eclipse.ice.build</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<modules>
<module>../org.eclipse.ice.parent</module>
<module>../org.eclipse.ice.dev</module>
<module>../org.eclipse.ice.archetypes</module>
<module>../org.eclipse.ice.commands</module>

</modules>
<modules>
<module>../org.eclipse.ice.data</module>
<module>../org.eclipse.ice.dev</module>
<module>../org.eclipse.ice.archetypes</module>
<module>../org.eclipse.ice.commands</module>
</modules>
</project>
Expand Up @@ -9,7 +9,7 @@
* Initial API and implementation and/or initial documentation - Jay Jay Billings,
* Joe Osborn
*******************************************************************************/
package org.eclipse.ice.tests.commands;
package org.eclipse.ice.commands;

import java.io.File;
import java.io.IOException;
Expand Down
Expand Up @@ -9,7 +9,7 @@
* Initial API and implementation and/or initial documentation -
* Jay Jay Billings, Joe Osborn
*******************************************************************************/
package org.eclipse.ice.tests.commands;
package org.eclipse.ice.commands;

import java.io.File;
import java.io.IOException;
Expand Down
Expand Up @@ -46,7 +46,7 @@
* @author Jay Jay Billings
*
*/
public class JavascriptValidator implements Serializable {
public class JavascriptValidator<T> implements Serializable {

/**
* Logging tool
Expand Down Expand Up @@ -88,7 +88,7 @@ public JavascriptValidator() {
* Copy constructor
* @param otherValidator to copy
*/
public JavascriptValidator(JavascriptValidator otherValidator) {
public JavascriptValidator(JavascriptValidator<T> otherValidator) {
if (otherValidator != null) {
function = otherValidator.function;
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public boolean equals(Object otherObject) {
retValue = true;
} else if (otherObject instanceof JavascriptValidator) {
@SuppressWarnings("unchecked")
JavascriptValidator otherValidator = (JavascriptValidator) otherObject;
JavascriptValidator<T> otherValidator = (JavascriptValidator<T>) otherObject;
retValue = this.function.equals(otherValidator.function);
}

Expand All @@ -153,7 +153,7 @@ public boolean equals(Object otherObject) {
* @throws NoSuchMethodException This exception is thrown if the Javascript
* validation function cannot be found.
*/
public boolean validate(final IDataElement data) throws NoSuchMethodException {
public boolean validate(final T data) throws NoSuchMethodException {

boolean retValue = false;
Object result = null;
Expand Down Expand Up @@ -196,7 +196,7 @@ public int hashCode() {
public Object clone() {
try {
// Call the copy constructor to create the clone.
return new JavascriptValidator(this);
return new JavascriptValidator<T>(this);
} catch (Exception e) {
logger.error("Unable to clone DataElement!", e);
return null;
Expand Down
Expand Up @@ -99,7 +99,7 @@ void testDefaultProps() {
assertEquals(element.isSecret(), secret);

// Make sure that adding validators works superficially
JavascriptValidator validator = new JavascriptValidator();
JavascriptValidator<GeneratedDataElement> validator = new JavascriptValidator<>();
element.setValidator(validator);
assertEquals(element.getValidator(), validator);

Expand Down Expand Up @@ -167,7 +167,7 @@ void testStringSerialization() {
GeneratedDataElement element = getStringElement("Major Lazer & La Roux");
element.setSecret(true);
element.setRequired(true);
element.setValidator(new JavascriptValidator());
element.setValidator(new JavascriptValidator<>());

// Because of the private id changing and being unique, this cannot be checked
// against a reference but can only be checked by inversion.
Expand All @@ -178,7 +178,7 @@ void testStringSerialization() {
element.setTestField("Eastern Sun");
System.out.println(output);
GeneratedDataElement element2 = getStringElement("Emancipator");
element2.setValidator(new JavascriptValidator());
element2.setValidator(new JavascriptValidator<>());
element2.fromJson(output);
element.fromJson(output);
assertEquals(element,element2);
Expand All @@ -198,7 +198,7 @@ void testPOJOSerialization() {
element.setTestPOJO(new TestPOJO());
element.setSecret(true);
element.setRequired(true);
element.setValidator(new JavascriptValidator());
element.setValidator(new JavascriptValidator<>());

// Because of the private id changing and being unique, this cannot be checked
// against a reference but can only be checked by inversion.
Expand All @@ -209,7 +209,7 @@ void testPOJOSerialization() {
GeneratedDataElementPOJO element2 = new GeneratedDataElementPOJOImplementation();
TestPOJO pojo2 = new TestPOJO();
pojo2.setDoubleValue(1.072);
element2.setValidator(new JavascriptValidator());
element2.setValidator(new JavascriptValidator<>());
element2.setTestPOJO(pojo2);
element2.fromJson(output);

Expand All @@ -236,12 +236,12 @@ void testEquality() {
GeneratedDataElement element4 = getStringElement("Halsey");

// Need a validator for the tests that is shared on the equal elements.
JavascriptValidator validator = new JavascriptValidator();
JavascriptValidator<GeneratedDataElement> validator = new JavascriptValidator<>();
element.setValidator(validator);
element2.setValidator(validator);
element4.setValidator(validator);
// Billie needs her own validator
element3.setValidator(new JavascriptValidator());
element3.setValidator(new JavascriptValidator<>());

// Data elements must be checked both for matching - a deep inequality except
// the UUID - and for a fully complete match that contains the UUID. Start with
Expand Down
Expand Up @@ -113,7 +113,7 @@ public class DefaultFields {
*/
private static Field validator = Field.builder()
.name("validator")
.type(JavascriptValidator.class)
.type(JavascriptValidator.class.getCanonicalName() + "<$interface>")
.docString("The validator used to check the correctness of the data.")
.nullable(true)
.defaultField(true)
Expand Down
Expand Up @@ -120,7 +120,7 @@ public static String getShortenedType(String type) {
matcher.appendReplacement(shortenedType, "$1");
}
matcher.appendTail(shortenedType);
return shortenedType.toString().replace("$", ".");
return shortenedType.toString();
}

/**
Expand All @@ -135,6 +135,7 @@ public Set<String> getImports() {
.map(entry -> entry.getValue())
// No need to import java.lang package
.filter(type -> !type.startsWith("java.lang"))
.filter(type -> !type.startsWith("$"))
.collect(Collectors.toSet());
}

Expand All @@ -148,9 +149,13 @@ public String resolve(String type) {
StringBuffer resolved = new StringBuffer();
Matcher matcher = TYPE_SHORTENER.matcher(type);
while (matcher.find()) {
String found = fullToShort.get(matcher.group());
if (found == null) {
found = matcher.group();
}
matcher.appendReplacement(
resolved,
fullToShort.get(matcher.group())
found
);
}
matcher.appendTail(resolved);
Expand Down
Expand Up @@ -44,7 +44,7 @@
#end

## Get evaluated field type
#macro(fieldtype)$types.resolve(${field.Type})#end
#macro(fieldtype)$types.resolve("#evaluate(${field.Type})")#end

## Get the type of this field for use in parameter list (includes nonnull)
#macro(fieldparametertype)#nonnull("", " ")#fieldtype#end
Expand Down
Expand Up @@ -30,8 +30,8 @@ void testGetShortenedType() {
assertEquals("UUID", Types.getShortenedType("java.util.UUID"));
assertEquals("Entry", Types.getShortenedType("java.util.Map.Entry"));
assertEquals(
"Map.Entry<String, Object>",
Types.getShortenedType("java.util.Map$Entry<String, Object>")
"Entry<String, Object>",
Types.getShortenedType("java.util.Map.Entry<String, Object>")
);
assertEquals(
"List<String>",
Expand Down
Expand Up @@ -19,5 +19,5 @@ public class TestImplementation implements Test, Serializable {
@NonNull protected String context = "default";
protected boolean required = false;
protected boolean secret = false;
protected JavascriptValidator validator;
protected JavascriptValidator<Test> validator;
}

0 comments on commit bac2200

Please sign in to comment.