This repository has been archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for 'int', 'long', 'float', and 'double expectedInputs
- **BREAKING CHANGE NOTE**: Clients (e.g. older versions of `jobson-ui`) may not be prepared to handle these new data types. Minor version bumped from 0.0.x to 0.1.x in both `jobson` and `jobson-ui` to reflect this. - Added support for numeric input types - 'int': 32-bit signed integer. Max/min value = (2^31)-1. Should be sent to API as a JSON number (e.g. `"inputId": 34833`). - 'long': 64-bit signed integer. Max/min value = (2^63)-1. Can be sent to the API as *either* a JSON number *or* a JSON string (clients may not support large in-memory numbers) - 'float': 32-bit IEE754 floating point number - 'long': 64-bit IEE754 floating point number
- Loading branch information
Showing
28 changed files
with
712 additions
and
54 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
45 changes: 45 additions & 0 deletions
45
jobson/src/main/java/com/github/jobson/jobinputs/f32/F32ExpectedInput.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,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.github.jobson.jobinputs.f32; | ||
|
||
import com.github.jobson.jobinputs.JobExpectedInput; | ||
import com.github.jobson.utils.ValidationError; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Random; | ||
|
||
public final class F32ExpectedInput extends JobExpectedInput<F32Input> { | ||
@Override | ||
public Class<F32Input> getExpectedInputClass() { | ||
return F32Input.class; | ||
} | ||
|
||
@Override | ||
public Optional<List<ValidationError>> validate(F32Input input) { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public F32Input generateExampleInput() { | ||
final float val = new Random().nextFloat(); | ||
return new F32Input(val); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
jobson/src/main/java/com/github/jobson/jobinputs/f32/F32Input.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,43 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.github.jobson.jobinputs.f32; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import com.github.jobson.jobinputs.JobInput; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
public final class F32Input implements JobInput { | ||
|
||
@NotNull | ||
private float value; | ||
|
||
@JsonCreator | ||
public F32Input(float value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return Float.toString(value); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
jobson/src/main/java/com/github/jobson/jobinputs/f64/F64ExpectedInput.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,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.github.jobson.jobinputs.f64; | ||
|
||
import com.github.jobson.jobinputs.JobExpectedInput; | ||
import com.github.jobson.utils.ValidationError; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Random; | ||
|
||
public final class F64ExpectedInput extends JobExpectedInput<F64Input> { | ||
@Override | ||
public Class<F64Input> getExpectedInputClass() { | ||
return F64Input.class; | ||
} | ||
|
||
@Override | ||
public Optional<List<ValidationError>> validate(F64Input input) { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public F64Input generateExampleInput() { | ||
final long value = new Random().nextLong(); | ||
return new F64Input(value); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
jobson/src/main/java/com/github/jobson/jobinputs/f64/F64Input.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,52 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.github.jobson.jobinputs.f64; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import com.github.jobson.jobinputs.JobInput; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
public final class F64Input implements JobInput { | ||
|
||
@NotNull | ||
private final double value; | ||
|
||
@JsonCreator | ||
public F64Input(double value) { | ||
this.value = value; | ||
} | ||
|
||
public F64Input(String value) { | ||
// The API may have to accept 64-bit doubles in string format because | ||
// javascript clients can't handle 64-bit binary decimals without losing | ||
// precision (after 16 significant digits, "real" doubles lose precision | ||
// after 21 digits). Because of this, clients *may* send a double as a string | ||
// which the server parses into a binary double server-side | ||
this.value = Double.parseDouble(value); | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return Double.toString(value); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
jobson/src/main/java/com/github/jobson/jobinputs/i32/I32ExpectedInput.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,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.github.jobson.jobinputs.i32; | ||
|
||
import com.github.jobson.jobinputs.JobExpectedInput; | ||
import com.github.jobson.utils.ValidationError; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Random; | ||
|
||
public final class I32ExpectedInput extends JobExpectedInput<I32Input> { | ||
@Override | ||
public Class<I32Input> getExpectedInputClass() { | ||
return I32Input.class; | ||
} | ||
|
||
@Override | ||
public Optional<List<ValidationError>> validate(I32Input input) { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public I32Input generateExampleInput() { | ||
final int value = new Random().nextInt(); | ||
return new I32Input(value); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
jobson/src/main/java/com/github/jobson/jobinputs/i32/I32Input.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,43 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.github.jobson.jobinputs.i32; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import com.github.jobson.jobinputs.JobInput; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
public final class I32Input implements JobInput { | ||
|
||
@NotNull | ||
private final int value; | ||
|
||
@JsonCreator | ||
public I32Input(int value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return Integer.toString(this.value); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
jobson/src/main/java/com/github/jobson/jobinputs/i64/I64ExpectedInput.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,45 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package com.github.jobson.jobinputs.i64; | ||
|
||
import com.github.jobson.jobinputs.JobExpectedInput; | ||
import com.github.jobson.utils.ValidationError; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.Random; | ||
|
||
public final class I64ExpectedInput extends JobExpectedInput<I64Input> { | ||
@Override | ||
public Class<I64Input> getExpectedInputClass() { | ||
return I64Input.class; | ||
} | ||
|
||
@Override | ||
public Optional<List<ValidationError>> validate(I64Input input) { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public I64Input generateExampleInput() { | ||
final long value = new Random().nextLong(); | ||
return new I64Input(value); | ||
} | ||
} |
Oops, something went wrong.