Skip to content

Commit

Permalink
gh-194: Migrate koryphe to Java 11. (#239)
Browse files Browse the repository at this point in the history
* gh-194: Migrate koryphe to Java 11.

* gh-194: Fix imports and change usages of requireNonNullOrElseGet to requireNonNullElse.

* gh-194: Fix headers.

Co-authored-by: t511203 <[email protected]>
Co-authored-by: t92549 <[email protected]>
  • Loading branch information
3 people authored Feb 10, 2022
1 parent 88d8b1c commit e04797e
Show file tree
Hide file tree
Showing 191 changed files with 952 additions and 309 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '8'
java-version: '11'

- name: Cache dependencies
uses: actions/cache@v2
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '8'
java-version: '11'

- name: Checkout master
uses: actions/checkout@v2
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '8'
java-version: '11'

- name: Merge release into develop
run: |
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '8'
java-version: '11'

- name: Set version
run: echo "RELEASE_VERSION=$(echo ${{ github.event.milestone.title }} | cut -c 2-)" >> $GITHUB_ENV
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '8'
java-version: '11'

- name: Checkout master
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Crown Copyright
# Copyright 2017-2020 Crown Copyright

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion NOTICES
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2017-2020 Crown Copyright
Copyright 2017-2022 Crown Copyright

Koryphe is built using maven. This process will automatically pull in dependencies. We list Koryphe's dependencies,
and their licenses, below. For information on the dependencies of these dependencies, see the websites of the
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2017-2020 Crown Copyright
Copyright 2017-2022 Crown Copyright

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -26,7 +26,7 @@ Koryphe is an extensible functions library for filtering, aggregating and transf

## Context adapted functions

Koryphe allows any Java 8 Function, BinaryOperator or Predicate to be adapted and applied to the values contained within a complex object such as a Tuple.
Koryphe allows any Java 11 Function, BinaryOperator or Predicate to be adapted and applied to the values contained within a complex object such as a Tuple.

## Function composition

Expand Down
10 changes: 2 additions & 8 deletions code-style/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
~ Copyright 2016-2020 Crown Copyright
~ Copyright 2016-2022 Crown Copyright
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,6 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<module name="Checker">
<module name="Translation"/>
<module name="FileLength"/>
Expand All @@ -38,14 +37,10 @@
</module>

<module name="TreeWalker">
<property name="cacheFile" value="${checkstyle.cache.file}"/>

<module name="SuppressWarningsHolder"/>

<module name="AtclauseOrder"/>
<module name="JavadocMethod">
<property name="allowMissingJavadoc" value="true"/>
</module>
<module name="JavadocMethod"/>
<module name="JavadocStyle">
<property name="checkFirstSentence" value="false"/>
</module>
Expand Down Expand Up @@ -88,7 +83,6 @@
<module name="WhitespaceAround"/>

<module name="ModifierOrder"/>
<module name="RedundantModifier"/>

<module name="AvoidNestedBlocks"/>
<module name="LeftCurly"/>
Expand Down
23 changes: 23 additions & 0 deletions code-style/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2022 Crown Copyright
~
~ Licensed 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.
-->
<FindBugsFilter xmlns="https://github.com/spotbugs/filter/3.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
<Match>
<Bug code="EI,EI2"/>
</Match>
</FindBugsFilter>
4 changes: 2 additions & 2 deletions core/src/main/java/uk/gov/gchq/koryphe/adapted/Adapted.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 Crown Copyright
* Copyright 2017-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -55,7 +55,7 @@ public BiFunction<C, AO, O> getOutputAdapter() {
return outputAdapter;
}

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
public void setOutputAdapter(final BiFunction<C, AO, O> outputAdapter) {
this.outputAdapter = outputAdapter;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 Crown Copyright
* Copyright 2017-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -48,7 +48,7 @@ public Function<I, AI> getInputAdapter() {
return inputAdapter;
}

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
public void setInputAdapter(final Function<I, AI> inputAdapter) {
this.inputAdapter = inputAdapter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@Since("1.11.0")
@Summary("Adapts an output without considering the state")
public class StateAgnosticOutputAdapter<T, U, R> implements BiFunction<T, U, R> {
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
private Function<U, R> adapter;

public StateAgnosticOutputAdapter() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 Crown Copyright
* Copyright 2017-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -81,7 +81,7 @@ public BinaryOperator<OT> getBinaryOperator() {
return binaryOperator;
}

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
public void setBinaryOperator(final BinaryOperator<OT> binaryOperator) {
this.binaryOperator = binaryOperator;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 Crown Copyright
* Copyright 2017-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,7 +33,7 @@
@Since("1.0.0")
@Summary("Merges 2 maps by applying a binary operator to each of the values")
public class BinaryOperatorMap<K, T> extends KorypheBinaryOperator<Map<K, T>> {
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
private BinaryOperator<? super T> binaryOperator;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 Crown Copyright
* Copyright 2017-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@
*
* @param <T> Input/Output type
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
public abstract class KorypheBinaryOperator<T> implements BinaryOperator<T> {
/**
* Apply the operator after completing null checks.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 Crown Copyright
* Copyright 2017-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,7 +40,7 @@ public Composite(final List<C> components) {
this.components = components;
}

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
public List<C> getComponents() {
return components;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 Crown Copyright
* Copyright 2017-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@
* @param <O> Output type
*/
public abstract class AdaptedFunction<I, FI, FO, O> extends Adapted<I, FI, FO, O, I> implements Function<I, O> {
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
protected Function<FI, FO> function;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 Crown Copyright
* Copyright 2017-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,7 +35,7 @@
@Since("1.0.0")
@Summary("Applies a function to each value in a map")
public class FunctionMap<K, I, O> extends KorypheFunction<Map<K, I>, Map<K, O>> {
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
private Function<I, O> function;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 Crown Copyright
* Copyright 2017-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,7 +26,7 @@
* @param <I> Input type
* @param <O> Output type
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
public abstract class KorypheFunction<I, O> implements Function<I, O> {
@Override
public boolean equals(final Object obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package uk.gov.gchq.koryphe.impl.binaryoperator;

import org.apache.commons.lang3.builder.ToStringBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package uk.gov.gchq.koryphe.impl.binaryoperator;

import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Crown Copyright
* Copyright 2019-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,7 +38,7 @@
* @param <U> Type of second input
* @param <R> Type of output
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
@Since("1.8.0")
@Summary("Applies the given BiFunction")
public class ApplyBiFunction<T, U, R> extends KorypheFunction2<T, U, R> implements WrappedBiFunction<T, U, R> {
Expand All @@ -57,7 +57,7 @@ public R apply(final T t, final U u) {
}

@Override
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "class")
public BiFunction<T, U, R> getFunction() {
return function;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Crown Copyright
* Copyright 2019-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,8 +56,8 @@ public Object apply(final Object value) {

if (isNull(value)) {
try {
return objectClass.newInstance();
} catch (final InstantiationException | IllegalAccessException e) {
return objectClass.getDeclaredConstructor().newInstance();
} catch (final InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
throw new RuntimeException("Unable to create a new instance of " + objectClass.getName() + " using the no-arg constructor", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Crown Copyright
* Copyright 2019-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -96,11 +96,12 @@ private CSVRecord parseCsv(final String csv) {
}

private CSVFormat getCsvFormat() {
CSVFormat format = CSVFormat.DEFAULT.withDelimiter(delimiter);
final CSVFormat.Builder formatBuilder = CSVFormat.DEFAULT.builder().setDelimiter(delimiter);
if (quoted) {
format = format.withQuote(quoteChar);
formatBuilder.setQuote(quoteChar);
}
return format;

return formatBuilder.build();
}

public List<String> getHeader() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Crown Copyright
* Copyright 2019-2022 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -82,11 +82,11 @@ private Map<String, Object> extractMap(final CSVRecord csvRecord) {
}

private CSVFormat getCsvFormat() {
CSVFormat format = CSVFormat.DEFAULT.withDelimiter(delimiter);
final CSVFormat.Builder formatBuilder = CSVFormat.DEFAULT.builder().setDelimiter(delimiter);
if (quoted) {
format = format.withQuote(quoteChar);
formatBuilder.setQuote(quoteChar);
}
return format;
return formatBuilder.build();
}

public List<String> getHeader() {
Expand Down
Loading

0 comments on commit e04797e

Please sign in to comment.