Skip to content

Commit

Permalink
- Removed unused/unnecessary code.
Browse files Browse the repository at this point in the history
- JcaTemplate tests now up to 100% coverage.
  • Loading branch information
lhazlewood committed Aug 22, 2023
1 parent 95b6699 commit 9517f27
Show file tree
Hide file tree
Showing 12 changed files with 423 additions and 504 deletions.
99 changes: 49 additions & 50 deletions impl/src/main/java/io/jsonwebtoken/impl/lang/Conditions.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package io.jsonwebtoken.impl.lang;

import io.jsonwebtoken.lang.Assert;

/**
* @since JJWT_RELEASE_VERSION
*/
Expand All @@ -25,37 +23,38 @@ public final class Conditions {
private Conditions() {
}

public static final Condition TRUE = of(true);

public static Condition of(boolean val) {
return new BooleanCondition(val);
}

public static Condition not(Condition c) {
return new NotCondition(c);
}

public static Condition exists(CheckedSupplier<?> s) {
return new ExistsCondition(s);
}

public static Condition notExists(CheckedSupplier<?> s) {
return not(exists(s));
}

private static final class NotCondition implements Condition {

private final Condition c;

private NotCondition(Condition c) {
this.c = Assert.notNull(c, "Condition cannot be null.");
}

@Override
public boolean test() {
return !c.test();
}
}
public static final Condition TRUE = new BooleanCondition(true);
public static final Condition FALSE = new BooleanCondition(false);

// public static Condition of(boolean val) {
// return new BooleanCondition(val);
// }

// public static Condition not(Condition c) {
// return new NotCondition(c);
// }

// public static Condition exists(CheckedSupplier<?> s) {
// return new ExistsCondition(s);
// }
//
// public static Condition notExists(CheckedSupplier<?> s) {
// return not(exists(s));
// }

// private static final class NotCondition implements Condition {
//
// private final Condition c;
//
// private NotCondition(Condition c) {
// this.c = Assert.notNull(c, "Condition cannot be null.");
// }
//
// @Override
// public boolean test() {
// return !c.test();
// }
// }

private static final class BooleanCondition implements Condition {
private final boolean value;
Expand All @@ -70,21 +69,21 @@ public boolean test() {
}
}

private static final class ExistsCondition implements Condition {
private final CheckedSupplier<?> supplier;

ExistsCondition(CheckedSupplier<?> supplier) {
this.supplier = Assert.notNull(supplier, "CheckedSupplier cannot be null.");
}

@Override
public boolean test() {
Object value = null;
try {
value = supplier.get();
} catch (Throwable ignored) {
}
return value != null;
}
}
// private static final class ExistsCondition implements Condition {
// private final CheckedSupplier<?> supplier;
//
// ExistsCondition(CheckedSupplier<?> supplier) {
// this.supplier = Assert.notNull(supplier, "CheckedSupplier cannot be null.");
// }
//
// @Override
// public boolean test() {
// Object value = null;
// try {
// value = supplier.get();
// } catch (Throwable ignored) {
// }
// return value != null;
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,12 @@
*/
public final class ConstantFunction<T, R> implements Function<T, R> {

private static final Function<?, ?> NULL = new ConstantFunction<>(null);

private final R value;

public ConstantFunction(R value) {
this.value = value;
}

@SuppressWarnings("unchecked")
public static <T, R> Function<T, R> forNull() {
return (Function<T, R>) NULL;
}

@Override
public R apply(T t) {
return this.value;
Expand Down
4 changes: 0 additions & 4 deletions impl/src/main/java/io/jsonwebtoken/impl/lang/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ public final class Functions {
private Functions() {
}

public static <T, R> Function<T, R> forNull() {
return ConstantFunction.forNull();
}

public static <T> Function<T, T> identity() {
return new Function<T, T>() {
@Override
Expand Down

This file was deleted.

Loading

0 comments on commit 9517f27

Please sign in to comment.