From 444cbdcc2a7a83df39a1db77f335f19deff1e78e Mon Sep 17 00:00:00 2001 From: HeZean Date: Thu, 1 Dec 2022 22:32:40 +0800 Subject: [PATCH] chore: add spotless format checker --- .github/misc/license-header | 17 +++ .github/misc/spotless-formatter.xml | 33 +++++ .github/workflows/build.yml | 4 + README.md | 7 +- pom.xml | 140 ++++++++++++------ .../sdk/example/FeatureProbeDemo.java | 28 +++- .../featureprobe/sdk/server/AccessEvent.java | 17 +++ .../sdk/server/AccessRecorder.java | 17 +++ .../sdk/server/DataRepository.java | 17 +++ .../sdk/server/DataRepositoryFactory.java | 17 +++ .../sdk/server/DatetimeMatcher.java | 17 +++ .../sdk/server/DefaultEventProcessor.java | 18 ++- .../server/DefaultEventProcessorFactory.java | 17 +++ .../sdk/server/EvaluationResult.java | 17 +++ .../com/featureprobe/sdk/server/Event.java | 17 +++ .../sdk/server/EventProcessor.java | 17 +++ .../sdk/server/EventProcessorFactory.java | 17 +++ .../com/featureprobe/sdk/server/FPConfig.java | 30 +++- .../featureprobe/sdk/server/FPContext.java | 21 ++- .../com/featureprobe/sdk/server/FPDetail.java | 17 +++ .../com/featureprobe/sdk/server/FPUser.java | 22 ++- .../featureprobe/sdk/server/FeatureProbe.java | 22 ++- .../sdk/server/FileSynchronizer.java | 17 +++ .../sdk/server/FileSynchronizerFactory.java | 17 +++ .../featureprobe/sdk/server/HitResult.java | 18 ++- .../sdk/server/HttpConfiguration.java | 19 ++- .../com/featureprobe/sdk/server/Loggers.java | 17 +++ .../sdk/server/MemoryDataRepository.java | 17 +++ .../server/MemoryDataRepositoryFactory.java | 17 +++ .../sdk/server/NumberMatcher.java | 17 +++ .../sdk/server/PollingSynchronizer.java | 17 +++ .../server/PollingSynchronizerFactory.java | 17 +++ .../sdk/server/SegmentMatcher.java | 17 +++ .../sdk/server/SemverMatcher.java | 17 +++ .../sdk/server/StringMatcher.java | 17 +++ .../featureprobe/sdk/server/Synchronizer.java | 17 +++ .../sdk/server/SynchronizerFactory.java | 17 +++ .../server/exceptions/HttpErrorException.java | 17 +++ .../sdk/server/model/Condition.java | 125 +++++++++------- .../sdk/server/model/ConditionType.java | 18 +++ .../sdk/server/model/Distribution.java | 18 ++- .../sdk/server/model/PredicateType.java | 21 ++- .../sdk/server/model/Repository.java | 17 +++ .../featureprobe/sdk/server/model/Rule.java | 17 +++ .../sdk/server/model/Segment.java | 17 +++ .../sdk/server/model/SegmentRule.java | 20 ++- .../featureprobe/sdk/server/model/Serve.java | 18 ++- .../featureprobe/sdk/server/model/Split.java | 17 +++ .../featureprobe/sdk/server/model/Toggle.java | 17 +++ 49 files changed, 972 insertions(+), 137 deletions(-) create mode 100644 .github/misc/license-header create mode 100644 .github/misc/spotless-formatter.xml diff --git a/.github/misc/license-header b/.github/misc/license-header new file mode 100644 index 0000000..29400e5 --- /dev/null +++ b/.github/misc/license-header @@ -0,0 +1,17 @@ +/* + * 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. + */ + diff --git a/.github/misc/spotless-formatter.xml b/.github/misc/spotless-formatter.xml new file mode 100644 index 0000000..9f166e3 --- /dev/null +++ b/.github/misc/spotless-formatter.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 145daef..c983c46 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,10 @@ jobs: java-version: '11' distribution: 'temurin' cache: maven + + - name: Spotless check + run: mvn spotless:check + - name: Build with Maven run: mvn -B package --file pom.xml diff --git a/README.md b/README.md index fda8533..595dcad 100644 --- a/README.md +++ b/README.md @@ -12,18 +12,17 @@ SDK is designed primarily for use in multi-user systems such as web servers and Reading the short [Introduction](https://docs.featureprobe.io/reference/sdk-introduction) will help to understand the code blow more easily. [中文](https://docs.featureprobe.io/zh-CN/reference/sdk-introduction) - ## How to Use This SDK See [SDK Doc](https://docs.featureprobe.io/how-to/Server-Side%20SDKs/java-sdk) for detail. [中文](https://docs.featureprobe.io/zh-CN/how-to/Server-Side%20SDKs/java-sdk) ## Contributing -We are working on continue evolving FeatureProbe core, making it flexible and easier to use. -Development of FeatureProbe happens in the open on GitHub, and we are grateful to the +We are working on continue evolving FeatureProbe core, making it flexible and easier to use. +Development of FeatureProbe happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. -Please read [CONTRIBUTING](https://github.com/FeatureProbe/featureprobe/blob/master/CONTRIBUTING.md) +Please read [CONTRIBUTING](https://github.com/FeatureProbe/featureprobe/blob/master/CONTRIBUTING.md) for details on our code of conduct, and the process for taking part in improving FeatureProbe. ## License diff --git a/pom.xml b/pom.xml index 1a66d3b..05eeb2f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,5 @@ - 4.0.0 @@ -8,34 +7,8 @@ server-sdk-java 1.4.0 server-sdk-java - https://github.com/FeatureProbe/server-sdk-java FeatureProbe Server Side SDK for Java - - - KaKa - KaKa Jiang - - lead developer - - - - - - - Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - A business-friendly OSS license - - - - - scm:git@github.com:FeatureProbe/server-sdk-java.git - scm:git@github.com:FeatureProbe/server-sdk-java.git - https://github.com/FeatureProbe/server-sdk-java - - 1.8 UTF-8 @@ -109,25 +82,29 @@ test - + + org.codehaus.groovy groovy ${groovy.version} test - + + net.bytebuddy byte-buddy 1.12.7 test - + + org.objenesis objenesis 3.2 test - + + org.hamcrest hamcrest-core 2.2 @@ -148,17 +125,6 @@ - - - ossrh - https://s01.oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ - - - @@ -191,7 +157,8 @@ maven-surefire-plugin 3.0.0-M5 - false + false + false **/*Test @@ -207,6 +174,48 @@ + + com.diffplug.spotless + spotless-maven-plugin + 2.25.0 + + + + .github/misc/spotless-formatter.xml + + + + .github/misc/license-header + + + + + UTF-8 + 4 + true + false + true + true + false + false + custom_1 + false + false + + + Leading blank line + project + project + + + + + **/*.md + + + + + org.jacoco jacoco-maven-plugin @@ -226,10 +235,10 @@ jacoco-site - test report + test @@ -289,10 +298,10 @@ sign-artifacts - verify sign + verify --pinentry-mode @@ -322,10 +331,10 @@ make-assembly - package single + package @@ -354,4 +363,41 @@ + https://github.com/FeatureProbe/server-sdk-java + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + A business-friendly OSS license + + + + + + KaKa + KaKa Jiang + + lead developer + + + + + + scm:git@github.com:FeatureProbe/server-sdk-java.git + scm:git@github.com:FeatureProbe/server-sdk-java.git + https://github.com/FeatureProbe/server-sdk-java + + + + + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots + + diff --git a/src/main/java/com/featureprobe/sdk/example/FeatureProbeDemo.java b/src/main/java/com/featureprobe/sdk/example/FeatureProbeDemo.java index 14f86b6..9c89736 100644 --- a/src/main/java/com/featureprobe/sdk/example/FeatureProbeDemo.java +++ b/src/main/java/com/featureprobe/sdk/example/FeatureProbeDemo.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.example; import com.featureprobe.sdk.server.FPConfig; @@ -19,19 +36,18 @@ public class FeatureProbeDemo { // FeatureProbe server URL for local docker private static final String FEATURE_PROBE_SERVER_URL = "http://localhost:4009/server"; // "https://featureprobe.io/server"; - // Server Side SDK Key for your project and environment public static final String FEATURE_PROBE_SERVER_SDK_KEY = "server-8ed48815ef044428826787e9a238b9c6a479f98c"; public static void main(String[] args) throws IOException { - Logger root = (Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); + Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); root.setLevel(Level.WARN); final FPConfig config = FPConfig.builder() - .remoteUri(FEATURE_PROBE_SERVER_URL) - .startWait(5L, TimeUnit.SECONDS) - .build(); + .remoteUri(FEATURE_PROBE_SERVER_URL) + .startWait(5L, TimeUnit.SECONDS) + .build(); // Init FeatureProbe, share this FeatureProbe instance in your project. final FeatureProbe fpClient = new FeatureProbe(FEATURE_PROBE_SERVER_SDK_KEY, config); @@ -42,7 +58,7 @@ public static void main(String[] args) throws IOException { // Create one user. FPUser user = new FPUser() - .with("userId", "00001"); // "userId" is used in rules, should be filled in. + .with("userId", "00001"); // "userId" is used in rules, should be filled in. // Get toggle result for this user. final String YOUR_TOGGLE_KEY = "campaign_allow_list"; diff --git a/src/main/java/com/featureprobe/sdk/server/AccessEvent.java b/src/main/java/com/featureprobe/sdk/server/AccessEvent.java index 0e0a851..624f2ce 100644 --- a/src/main/java/com/featureprobe/sdk/server/AccessEvent.java +++ b/src/main/java/com/featureprobe/sdk/server/AccessEvent.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; public class AccessEvent extends Event { diff --git a/src/main/java/com/featureprobe/sdk/server/AccessRecorder.java b/src/main/java/com/featureprobe/sdk/server/AccessRecorder.java index 9976d5e..c0dd319 100644 --- a/src/main/java/com/featureprobe/sdk/server/AccessRecorder.java +++ b/src/main/java/com/featureprobe/sdk/server/AccessRecorder.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import java.util.ArrayList; diff --git a/src/main/java/com/featureprobe/sdk/server/DataRepository.java b/src/main/java/com/featureprobe/sdk/server/DataRepository.java index aeb4579..0573845 100644 --- a/src/main/java/com/featureprobe/sdk/server/DataRepository.java +++ b/src/main/java/com/featureprobe/sdk/server/DataRepository.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import com.featureprobe.sdk.server.model.Repository; diff --git a/src/main/java/com/featureprobe/sdk/server/DataRepositoryFactory.java b/src/main/java/com/featureprobe/sdk/server/DataRepositoryFactory.java index 39cc2f4..db9735c 100644 --- a/src/main/java/com/featureprobe/sdk/server/DataRepositoryFactory.java +++ b/src/main/java/com/featureprobe/sdk/server/DataRepositoryFactory.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; public interface DataRepositoryFactory { diff --git a/src/main/java/com/featureprobe/sdk/server/DatetimeMatcher.java b/src/main/java/com/featureprobe/sdk/server/DatetimeMatcher.java index b459f5d..8526537 100644 --- a/src/main/java/com/featureprobe/sdk/server/DatetimeMatcher.java +++ b/src/main/java/com/featureprobe/sdk/server/DatetimeMatcher.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import java.util.List; diff --git a/src/main/java/com/featureprobe/sdk/server/DefaultEventProcessor.java b/src/main/java/com/featureprobe/sdk/server/DefaultEventProcessor.java index 6f61349..b61d9b7 100644 --- a/src/main/java/com/featureprobe/sdk/server/DefaultEventProcessor.java +++ b/src/main/java/com/featureprobe/sdk/server/DefaultEventProcessor.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import com.fasterxml.jackson.databind.ObjectMapper; @@ -53,7 +70,6 @@ public class DefaultEventProcessor implements EventProcessor { private static final String LOG_SENDER_ERROR = "Unexpected error from event sender"; private static final String LOG_BUSY_EVENT = "Event processing is busy, some will be dropped"; - ThreadFactory threadFactory = new ThreadFactoryBuilder() .setDaemon(true) .setNameFormat("FeatureProbe-event-handle-%d") diff --git a/src/main/java/com/featureprobe/sdk/server/DefaultEventProcessorFactory.java b/src/main/java/com/featureprobe/sdk/server/DefaultEventProcessorFactory.java index 033b327..4274c0e 100644 --- a/src/main/java/com/featureprobe/sdk/server/DefaultEventProcessorFactory.java +++ b/src/main/java/com/featureprobe/sdk/server/DefaultEventProcessorFactory.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; public class DefaultEventProcessorFactory implements EventProcessorFactory { diff --git a/src/main/java/com/featureprobe/sdk/server/EvaluationResult.java b/src/main/java/com/featureprobe/sdk/server/EvaluationResult.java index fc3a142..c3229fd 100644 --- a/src/main/java/com/featureprobe/sdk/server/EvaluationResult.java +++ b/src/main/java/com/featureprobe/sdk/server/EvaluationResult.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import java.util.Optional; diff --git a/src/main/java/com/featureprobe/sdk/server/Event.java b/src/main/java/com/featureprobe/sdk/server/Event.java index 00087d2..aafcb8d 100644 --- a/src/main/java/com/featureprobe/sdk/server/Event.java +++ b/src/main/java/com/featureprobe/sdk/server/Event.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; public class Event { diff --git a/src/main/java/com/featureprobe/sdk/server/EventProcessor.java b/src/main/java/com/featureprobe/sdk/server/EventProcessor.java index df8f85c..0c4b71d 100644 --- a/src/main/java/com/featureprobe/sdk/server/EventProcessor.java +++ b/src/main/java/com/featureprobe/sdk/server/EventProcessor.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; public interface EventProcessor { diff --git a/src/main/java/com/featureprobe/sdk/server/EventProcessorFactory.java b/src/main/java/com/featureprobe/sdk/server/EventProcessorFactory.java index 558c246..d9bdaff 100644 --- a/src/main/java/com/featureprobe/sdk/server/EventProcessorFactory.java +++ b/src/main/java/com/featureprobe/sdk/server/EventProcessorFactory.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; public interface EventProcessorFactory { diff --git a/src/main/java/com/featureprobe/sdk/server/FPConfig.java b/src/main/java/com/featureprobe/sdk/server/FPConfig.java index e63d3b9..418c5ac 100644 --- a/src/main/java/com/featureprobe/sdk/server/FPConfig.java +++ b/src/main/java/com/featureprobe/sdk/server/FPConfig.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import java.net.URI; @@ -15,7 +32,6 @@ public final class FPConfig { protected static final FPConfig DEFAULT = new Builder().build(); - final Duration refreshInterval; final Long startWait; @@ -40,13 +56,13 @@ protected FPConfig(Builder builder) { this.refreshInterval = builder.refreshInterval; this.remoteUri = builder.remoteUri; this.location = builder.location; - this.synchronizerFactory = builder.synchronizer == null ? new PollingSynchronizerFactory() : - builder.synchronizer; - this.dataRepositoryFactory = builder.dataRepository == null ? new MemoryDataRepositoryFactory() : - builder.dataRepository; + this.synchronizerFactory = + builder.synchronizer == null ? new PollingSynchronizerFactory() : builder.synchronizer; + this.dataRepositoryFactory = + builder.dataRepository == null ? new MemoryDataRepositoryFactory() : builder.dataRepository; this.eventProcessorFactory = new DefaultEventProcessorFactory(); - this.httpConfiguration = builder.httpConfiguration == null ? HttpConfiguration.DEFAULT : - builder.httpConfiguration; + this.httpConfiguration = + builder.httpConfiguration == null ? HttpConfiguration.DEFAULT : builder.httpConfiguration; this.synchronizerUrl = builder.synchronizerUrl; this.eventUrl = builder.eventUrl; this.startWait = builder.startWait == null ? DEFAULT_START_WAIT : builder.startWait; diff --git a/src/main/java/com/featureprobe/sdk/server/FPContext.java b/src/main/java/com/featureprobe/sdk/server/FPContext.java index aedd3b3..3e222d5 100644 --- a/src/main/java/com/featureprobe/sdk/server/FPContext.java +++ b/src/main/java/com/featureprobe/sdk/server/FPContext.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import okhttp3.Headers; @@ -26,9 +43,9 @@ final class FPContext { private static final String POST_EVENTS_DATA_API = "/api/events"; - private URL synchronizerUrl; + private URL synchronizerUrl; - private URL eventUrl; + private URL eventUrl; private final String serverSdkKey; diff --git a/src/main/java/com/featureprobe/sdk/server/FPDetail.java b/src/main/java/com/featureprobe/sdk/server/FPDetail.java index e1be523..d736025 100644 --- a/src/main/java/com/featureprobe/sdk/server/FPDetail.java +++ b/src/main/java/com/featureprobe/sdk/server/FPDetail.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import java.util.Optional; diff --git a/src/main/java/com/featureprobe/sdk/server/FPUser.java b/src/main/java/com/featureprobe/sdk/server/FPUser.java index 43531ad..4ca95ab 100644 --- a/src/main/java/com/featureprobe/sdk/server/FPUser.java +++ b/src/main/java/com/featureprobe/sdk/server/FPUser.java @@ -1,8 +1,25 @@ +/* + * 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.featureprobe.sdk.server; + import java.util.HashMap; import java.util.Map; - /** * A collection of attributes that can affect toggle evaluation, usually corresponding to a user of your application. */ @@ -15,7 +32,8 @@ public class FPUser { /** * Creates a new FPUser */ - public FPUser() {} + public FPUser() { + } /** * Creates a new FPUser diff --git a/src/main/java/com/featureprobe/sdk/server/FeatureProbe.java b/src/main/java/com/featureprobe/sdk/server/FeatureProbe.java index bcfeea2..5e25ee0 100644 --- a/src/main/java/com/featureprobe/sdk/server/FeatureProbe.java +++ b/src/main/java/com/featureprobe/sdk/server/FeatureProbe.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import com.fasterxml.jackson.core.JsonProcessingException; @@ -180,7 +197,6 @@ public void flush() { eventProcessor.flush(); } - /** * Safely shut down FeatureProbe instance * @throws IOException @@ -272,8 +288,8 @@ private FPDetail genericEvaluateDetail(String toggleKey, FPUser user, T d } private FPDetail getEvaluateDetail(String toggleKey, FPUser user, T defaultValue, - Class clazz, boolean isJson) - throws ClassCastException, JsonProcessingException { + Class clazz, + boolean isJson) throws ClassCastException, JsonProcessingException { FPDetail detail = new FPDetail<>(); if (this.dataRepository.initialized()) { Toggle toggle = dataRepository.getToggle(toggleKey); diff --git a/src/main/java/com/featureprobe/sdk/server/FileSynchronizer.java b/src/main/java/com/featureprobe/sdk/server/FileSynchronizer.java index 65454b5..640b3dd 100644 --- a/src/main/java/com/featureprobe/sdk/server/FileSynchronizer.java +++ b/src/main/java/com/featureprobe/sdk/server/FileSynchronizer.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import com.fasterxml.jackson.databind.DeserializationFeature; diff --git a/src/main/java/com/featureprobe/sdk/server/FileSynchronizerFactory.java b/src/main/java/com/featureprobe/sdk/server/FileSynchronizerFactory.java index 91ee939..a4404e0 100644 --- a/src/main/java/com/featureprobe/sdk/server/FileSynchronizerFactory.java +++ b/src/main/java/com/featureprobe/sdk/server/FileSynchronizerFactory.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; public final class FileSynchronizerFactory implements SynchronizerFactory { diff --git a/src/main/java/com/featureprobe/sdk/server/HitResult.java b/src/main/java/com/featureprobe/sdk/server/HitResult.java index a5be46c..4003b51 100644 --- a/src/main/java/com/featureprobe/sdk/server/HitResult.java +++ b/src/main/java/com/featureprobe/sdk/server/HitResult.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import java.util.Optional; @@ -10,7 +27,6 @@ public final class HitResult { private Optional reason = Optional.empty(); - public HitResult(boolean result) { this.hit = result; } diff --git a/src/main/java/com/featureprobe/sdk/server/HttpConfiguration.java b/src/main/java/com/featureprobe/sdk/server/HttpConfiguration.java index 2f5be0b..596e316 100644 --- a/src/main/java/com/featureprobe/sdk/server/HttpConfiguration.java +++ b/src/main/java/com/featureprobe/sdk/server/HttpConfiguration.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import okhttp3.ConnectionPool; @@ -34,7 +51,7 @@ protected HttpConfiguration(Builder builder) { this.connectTimeout = Builder.connectTimeout; this.readTimeout = Builder.readTimeout; this.writeTimeout = Builder.writeTimeout; - this.headers = Builder.headers; + this.headers = Builder.headers; } public static Builder builder() { diff --git a/src/main/java/com/featureprobe/sdk/server/Loggers.java b/src/main/java/com/featureprobe/sdk/server/Loggers.java index c25a60c..d120a1d 100644 --- a/src/main/java/com/featureprobe/sdk/server/Loggers.java +++ b/src/main/java/com/featureprobe/sdk/server/Loggers.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import org.slf4j.Logger; diff --git a/src/main/java/com/featureprobe/sdk/server/MemoryDataRepository.java b/src/main/java/com/featureprobe/sdk/server/MemoryDataRepository.java index 79c0c99..6b2b160 100644 --- a/src/main/java/com/featureprobe/sdk/server/MemoryDataRepository.java +++ b/src/main/java/com/featureprobe/sdk/server/MemoryDataRepository.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import com.featureprobe.sdk.server.model.Repository; diff --git a/src/main/java/com/featureprobe/sdk/server/MemoryDataRepositoryFactory.java b/src/main/java/com/featureprobe/sdk/server/MemoryDataRepositoryFactory.java index 7f7c83b..701090d 100644 --- a/src/main/java/com/featureprobe/sdk/server/MemoryDataRepositoryFactory.java +++ b/src/main/java/com/featureprobe/sdk/server/MemoryDataRepositoryFactory.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; final class MemoryDataRepositoryFactory implements DataRepositoryFactory { diff --git a/src/main/java/com/featureprobe/sdk/server/NumberMatcher.java b/src/main/java/com/featureprobe/sdk/server/NumberMatcher.java index ca7f4b1..a6ddf11 100644 --- a/src/main/java/com/featureprobe/sdk/server/NumberMatcher.java +++ b/src/main/java/com/featureprobe/sdk/server/NumberMatcher.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import java.util.List; diff --git a/src/main/java/com/featureprobe/sdk/server/PollingSynchronizer.java b/src/main/java/com/featureprobe/sdk/server/PollingSynchronizer.java index e0d13d6..2a031e0 100644 --- a/src/main/java/com/featureprobe/sdk/server/PollingSynchronizer.java +++ b/src/main/java/com/featureprobe/sdk/server/PollingSynchronizer.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import com.fasterxml.jackson.databind.DeserializationFeature; diff --git a/src/main/java/com/featureprobe/sdk/server/PollingSynchronizerFactory.java b/src/main/java/com/featureprobe/sdk/server/PollingSynchronizerFactory.java index 46a90a4..979b526 100644 --- a/src/main/java/com/featureprobe/sdk/server/PollingSynchronizerFactory.java +++ b/src/main/java/com/featureprobe/sdk/server/PollingSynchronizerFactory.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; public final class PollingSynchronizerFactory implements SynchronizerFactory { diff --git a/src/main/java/com/featureprobe/sdk/server/SegmentMatcher.java b/src/main/java/com/featureprobe/sdk/server/SegmentMatcher.java index 3212c4f..af82dcd 100644 --- a/src/main/java/com/featureprobe/sdk/server/SegmentMatcher.java +++ b/src/main/java/com/featureprobe/sdk/server/SegmentMatcher.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import com.featureprobe.sdk.server.model.Segment; diff --git a/src/main/java/com/featureprobe/sdk/server/SemverMatcher.java b/src/main/java/com/featureprobe/sdk/server/SemverMatcher.java index a2010f3..a4a538c 100644 --- a/src/main/java/com/featureprobe/sdk/server/SemverMatcher.java +++ b/src/main/java/com/featureprobe/sdk/server/SemverMatcher.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import org.apache.maven.artifact.versioning.ComparableVersion; diff --git a/src/main/java/com/featureprobe/sdk/server/StringMatcher.java b/src/main/java/com/featureprobe/sdk/server/StringMatcher.java index b32af72..c6f0109 100644 --- a/src/main/java/com/featureprobe/sdk/server/StringMatcher.java +++ b/src/main/java/com/featureprobe/sdk/server/StringMatcher.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import java.util.List; diff --git a/src/main/java/com/featureprobe/sdk/server/Synchronizer.java b/src/main/java/com/featureprobe/sdk/server/Synchronizer.java index 8982ebd..1483a1f 100644 --- a/src/main/java/com/featureprobe/sdk/server/Synchronizer.java +++ b/src/main/java/com/featureprobe/sdk/server/Synchronizer.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; import java.io.Closeable; diff --git a/src/main/java/com/featureprobe/sdk/server/SynchronizerFactory.java b/src/main/java/com/featureprobe/sdk/server/SynchronizerFactory.java index a182f56..b8a9cab 100644 --- a/src/main/java/com/featureprobe/sdk/server/SynchronizerFactory.java +++ b/src/main/java/com/featureprobe/sdk/server/SynchronizerFactory.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server; public interface SynchronizerFactory { diff --git a/src/main/java/com/featureprobe/sdk/server/exceptions/HttpErrorException.java b/src/main/java/com/featureprobe/sdk/server/exceptions/HttpErrorException.java index 52cce95..aa42276 100644 --- a/src/main/java/com/featureprobe/sdk/server/exceptions/HttpErrorException.java +++ b/src/main/java/com/featureprobe/sdk/server/exceptions/HttpErrorException.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.exceptions; public final class HttpErrorException extends RuntimeException { diff --git a/src/main/java/com/featureprobe/sdk/server/model/Condition.java b/src/main/java/com/featureprobe/sdk/server/model/Condition.java index 62a0629..3823fe4 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/Condition.java +++ b/src/main/java/com/featureprobe/sdk/server/model/Condition.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.model; import com.featureprobe.sdk.server.*; @@ -35,62 +52,58 @@ public final class Condition { static { - stringMatchers.put(PredicateType.IS_ONE_OF, (target, objects) -> - objects.contains(target)); - stringMatchers.put(PredicateType.ENDS_WITH, (target, objects) -> - objects.stream().anyMatch(target::endsWith)); - stringMatchers.put(PredicateType.STARTS_WITH, (target, objects) -> - objects.stream().anyMatch(target::startsWith)); - stringMatchers.put(PredicateType.CONTAINS, (target, objects) -> - objects.stream().anyMatch(target::contains)); - stringMatchers.put(PredicateType.MATCHES_REGEX, (target, objects) -> - objects.stream().anyMatch(s -> Pattern.compile(s).matcher(target).find())); - stringMatchers.put(PredicateType.IS_NOT_ANY_OF, (target, objects) -> - !objects.contains(target)); - stringMatchers.put(PredicateType.DOES_NOT_END_WITH, (target, objects) -> - objects.stream().noneMatch(target::endsWith)); - stringMatchers.put(PredicateType.DOES_NOT_START_WITH, (target, objects) -> - objects.stream().noneMatch(target::startsWith)); - stringMatchers.put(PredicateType.DOES_NOT_CONTAIN, (target, objects) -> - objects.stream().noneMatch(target::contains)); - stringMatchers.put(PredicateType.DOES_NOT_MATCH_REGEX, (target, objects) -> - objects.stream().noneMatch(s -> Pattern.compile(s).matcher(target).find())); - - segmentMatchers.put(PredicateType.IS_IN, (user, segments, objects) -> - objects.stream().anyMatch(s -> segments.get(s).contains(user, segments))); - segmentMatchers.put(PredicateType.IS_NOT_IN, (user, segments, objects) -> - objects.stream().noneMatch(s -> segments.get(s).contains(user, segments))); - - datetimeMatchers.put(PredicateType.AFTER, ((target, objects) -> - objects.stream().map(Long::parseLong).anyMatch(o -> target >= o))); - datetimeMatchers.put(PredicateType.BEFORE, ((target, objects) -> - objects.stream().map(Long::parseLong).anyMatch(o -> target < o))); - - numberMatchers.put(PredicateType.EQUAL_TO, ((target, objects) -> - objects.stream().map(Double::parseDouble).anyMatch(o -> target == o))); - numberMatchers.put(PredicateType.NOT_EQUAL_TO, ((target, objects) -> - objects.stream().map(Double::parseDouble).noneMatch(o -> target == o))); - numberMatchers.put(PredicateType.GREATER_THAN, ((target, objects) -> - objects.stream().map(Double::parseDouble).anyMatch(o -> target > o))); - numberMatchers.put(PredicateType.GREATER_OR_EQUAL, ((target, objects) -> - objects.stream().map(Double::parseDouble).anyMatch(o -> target >= o))); - numberMatchers.put(PredicateType.LESS_THAN, ((target, objects) -> - objects.stream().map(Double::parseDouble).anyMatch(o -> target < o))); - numberMatchers.put(PredicateType.LESS_OR_EQUAL, ((target, objects) -> - objects.stream().map(Double::parseDouble).anyMatch(o -> target <= o))); - - semverMatchers.put(PredicateType.EQUAL_TO, ((target, objects) -> - objects.stream().filter(Objects::nonNull).map(ComparableVersion::new).anyMatch(t -> target.compareTo(t) == 0))); - semverMatchers.put(PredicateType.NOT_EQUAL_TO, ((target, objects) -> - objects.stream().filter(Objects::nonNull).map(ComparableVersion::new).noneMatch(t -> target.compareTo(t) == 0))); - semverMatchers.put(PredicateType.GREATER_THAN, ((target, objects) -> - objects.stream().filter(Objects::nonNull).map(ComparableVersion::new).anyMatch(t -> target.compareTo(t) > 0))); - semverMatchers.put(PredicateType.GREATER_OR_EQUAL, ((target, objects) -> - objects.stream().filter(Objects::nonNull).map(ComparableVersion::new).anyMatch(t -> target.compareTo(t) >= 0))); - semverMatchers.put(PredicateType.LESS_THAN, ((target, objects) -> - objects.stream().filter(Objects::nonNull).map(ComparableVersion::new).anyMatch(t -> target.compareTo(t) < 0))); - semverMatchers.put(PredicateType.LESS_OR_EQUAL, ((target, objects) -> - objects.stream().filter(Objects::nonNull).map(ComparableVersion::new).anyMatch(t -> target.compareTo(t) <= 0))); + stringMatchers.put(PredicateType.IS_ONE_OF, (target, objects) -> objects.contains(target)); + stringMatchers.put(PredicateType.ENDS_WITH, (target, objects) -> objects.stream().anyMatch(target::endsWith)); + stringMatchers.put(PredicateType.STARTS_WITH, + (target, objects) -> objects.stream().anyMatch(target::startsWith)); + stringMatchers.put(PredicateType.CONTAINS, (target, objects) -> objects.stream().anyMatch(target::contains)); + stringMatchers.put(PredicateType.MATCHES_REGEX, + (target, objects) -> objects.stream().anyMatch(s -> Pattern.compile(s).matcher(target).find())); + stringMatchers.put(PredicateType.IS_NOT_ANY_OF, (target, objects) -> !objects.contains(target)); + stringMatchers.put(PredicateType.DOES_NOT_END_WITH, + (target, objects) -> objects.stream().noneMatch(target::endsWith)); + stringMatchers.put(PredicateType.DOES_NOT_START_WITH, + (target, objects) -> objects.stream().noneMatch(target::startsWith)); + stringMatchers.put(PredicateType.DOES_NOT_CONTAIN, + (target, objects) -> objects.stream().noneMatch(target::contains)); + stringMatchers.put(PredicateType.DOES_NOT_MATCH_REGEX, + (target, objects) -> objects.stream().noneMatch(s -> Pattern.compile(s).matcher(target).find())); + + segmentMatchers.put(PredicateType.IS_IN, + (user, segments, objects) -> objects.stream().anyMatch(s -> segments.get(s).contains(user, segments))); + segmentMatchers.put(PredicateType.IS_NOT_IN, + (user, segments, objects) -> objects.stream().noneMatch(s -> segments.get(s).contains(user, segments))); + + datetimeMatchers.put(PredicateType.AFTER, + ((target, objects) -> objects.stream().map(Long::parseLong).anyMatch(o -> target >= o))); + datetimeMatchers.put(PredicateType.BEFORE, + ((target, objects) -> objects.stream().map(Long::parseLong).anyMatch(o -> target < o))); + + numberMatchers.put(PredicateType.EQUAL_TO, + ((target, objects) -> objects.stream().map(Double::parseDouble).anyMatch(o -> target == o))); + numberMatchers.put(PredicateType.NOT_EQUAL_TO, + ((target, objects) -> objects.stream().map(Double::parseDouble).noneMatch(o -> target == o))); + numberMatchers.put(PredicateType.GREATER_THAN, + ((target, objects) -> objects.stream().map(Double::parseDouble).anyMatch(o -> target > o))); + numberMatchers.put(PredicateType.GREATER_OR_EQUAL, + ((target, objects) -> objects.stream().map(Double::parseDouble).anyMatch(o -> target >= o))); + numberMatchers.put(PredicateType.LESS_THAN, + ((target, objects) -> objects.stream().map(Double::parseDouble).anyMatch(o -> target < o))); + numberMatchers.put(PredicateType.LESS_OR_EQUAL, + ((target, objects) -> objects.stream().map(Double::parseDouble).anyMatch(o -> target <= o))); + + semverMatchers.put(PredicateType.EQUAL_TO, ((target, objects) -> objects.stream().filter(Objects::nonNull) + .map(ComparableVersion::new).anyMatch(t -> target.compareTo(t) == 0))); + semverMatchers.put(PredicateType.NOT_EQUAL_TO, ((target, objects) -> objects.stream().filter(Objects::nonNull) + .map(ComparableVersion::new).noneMatch(t -> target.compareTo(t) == 0))); + semverMatchers.put(PredicateType.GREATER_THAN, ((target, objects) -> objects.stream().filter(Objects::nonNull) + .map(ComparableVersion::new).anyMatch(t -> target.compareTo(t) > 0))); + semverMatchers.put(PredicateType.GREATER_OR_EQUAL, ((target, objects) -> objects.stream() + .filter(Objects::nonNull).map(ComparableVersion::new).anyMatch(t -> target.compareTo(t) >= 0))); + semverMatchers.put(PredicateType.LESS_THAN, ((target, objects) -> objects.stream().filter(Objects::nonNull) + .map(ComparableVersion::new).anyMatch(t -> target.compareTo(t) < 0))); + semverMatchers.put(PredicateType.LESS_OR_EQUAL, ((target, objects) -> objects.stream().filter(Objects::nonNull) + .map(ComparableVersion::new).anyMatch(t -> target.compareTo(t) <= 0))); } diff --git a/src/main/java/com/featureprobe/sdk/server/model/ConditionType.java b/src/main/java/com/featureprobe/sdk/server/model/ConditionType.java index 7357887..f020ada 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/ConditionType.java +++ b/src/main/java/com/featureprobe/sdk/server/model/ConditionType.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.model; import com.fasterxml.jackson.annotation.JsonCreator; @@ -8,6 +25,7 @@ import java.util.stream.Collectors; public enum ConditionType { + STRING("string"), SEGMENT("segment"), DATETIME("datetime"), diff --git a/src/main/java/com/featureprobe/sdk/server/model/Distribution.java b/src/main/java/com/featureprobe/sdk/server/model/Distribution.java index dc99d38..f10a7d6 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/Distribution.java +++ b/src/main/java/com/featureprobe/sdk/server/model/Distribution.java @@ -1,5 +1,21 @@ -package com.featureprobe.sdk.server.model; +/* + * 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.featureprobe.sdk.server.model; import java.util.List; diff --git a/src/main/java/com/featureprobe/sdk/server/model/PredicateType.java b/src/main/java/com/featureprobe/sdk/server/model/PredicateType.java index daae4aa..545d7f4 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/PredicateType.java +++ b/src/main/java/com/featureprobe/sdk/server/model/PredicateType.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.model; import com.fasterxml.jackson.annotation.JsonCreator; @@ -22,19 +39,16 @@ public enum PredicateType { DOES_NOT_CONTAIN("does not contain"), DOES_NOT_MATCH_REGEX("does not match regex"), - // segment predicates IS_IN("is in"), IS_NOT_IN("is not in"), - // datetime predicates AFTER("after"), BEFORE("before"), - // number predicates // semver predicates @@ -45,7 +59,6 @@ public enum PredicateType { LESS_THAN("<"), LESS_OR_EQUAL("<="); - private final String value; private static final Map namesMap = Arrays.stream(PredicateType.values()) diff --git a/src/main/java/com/featureprobe/sdk/server/model/Repository.java b/src/main/java/com/featureprobe/sdk/server/model/Repository.java index fb779a5..a576856 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/Repository.java +++ b/src/main/java/com/featureprobe/sdk/server/model/Repository.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.model; import java.util.Map; diff --git a/src/main/java/com/featureprobe/sdk/server/model/Rule.java b/src/main/java/com/featureprobe/sdk/server/model/Rule.java index 87fc250..fa18d06 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/Rule.java +++ b/src/main/java/com/featureprobe/sdk/server/model/Rule.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.model; import com.featureprobe.sdk.server.FPUser; diff --git a/src/main/java/com/featureprobe/sdk/server/model/Segment.java b/src/main/java/com/featureprobe/sdk/server/model/Segment.java index 93b06d8..4ae8514 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/Segment.java +++ b/src/main/java/com/featureprobe/sdk/server/model/Segment.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.model; import com.featureprobe.sdk.server.FPUser; diff --git a/src/main/java/com/featureprobe/sdk/server/model/SegmentRule.java b/src/main/java/com/featureprobe/sdk/server/model/SegmentRule.java index fa5162f..4a96008 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/SegmentRule.java +++ b/src/main/java/com/featureprobe/sdk/server/model/SegmentRule.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.model; import com.featureprobe.sdk.server.FPUser; @@ -11,7 +28,8 @@ public class SegmentRule { private List conditions; - public SegmentRule(){} + public SegmentRule() { + } public SegmentRule(List conditions) { this.conditions = conditions; diff --git a/src/main/java/com/featureprobe/sdk/server/model/Serve.java b/src/main/java/com/featureprobe/sdk/server/model/Serve.java index 5dc2f8e..4eab8b1 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/Serve.java +++ b/src/main/java/com/featureprobe/sdk/server/model/Serve.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.model; import com.fasterxml.jackson.annotation.JsonInclude; @@ -32,7 +49,6 @@ public HitResult evalIndex(FPUser user, String toggleKey) { return split.findIndex(user, toggleKey); } - public Integer getSelect() { return select; } diff --git a/src/main/java/com/featureprobe/sdk/server/model/Split.java b/src/main/java/com/featureprobe/sdk/server/model/Split.java index ec22028..7c1b791 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/Split.java +++ b/src/main/java/com/featureprobe/sdk/server/model/Split.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.model; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/com/featureprobe/sdk/server/model/Toggle.java b/src/main/java/com/featureprobe/sdk/server/model/Toggle.java index 1366b77..a913110 100644 --- a/src/main/java/com/featureprobe/sdk/server/model/Toggle.java +++ b/src/main/java/com/featureprobe/sdk/server/model/Toggle.java @@ -1,3 +1,20 @@ +/* + * 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.featureprobe.sdk.server.model; import com.featureprobe.sdk.server.EvaluationResult;