-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from lanwen/misc
fix "Unknown content type null" in logs and since for 1.12.0 api
- Loading branch information
Showing
10 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/org/jenkinsci/plugins/github/util/misc/NullSafeFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.jenkinsci.plugins.github.util.misc; | ||
|
||
import com.google.common.base.Function; | ||
import com.google.common.base.Preconditions; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* This abstract class calls {@link #applyNullSafe(Object)} only after success validation of inner object for null | ||
* | ||
* @author lanwen (Merkushev Kirill) | ||
*/ | ||
public abstract class NullSafeFunction<F, T> implements Function<F, T> { | ||
|
||
@Override | ||
public T apply(@Nullable F input) { | ||
return applyNullSafe(Preconditions.checkNotNull(input, "This function not allows to use null as argument")); | ||
} | ||
|
||
/** | ||
* This method will be called inside of {@link #apply(Object)} | ||
*/ | ||
protected abstract T applyNullSafe(@Nonnull F input); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/org/jenkinsci/plugins/github/util/misc/NullSafePredicate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.jenkinsci.plugins.github.util.misc; | ||
|
||
import com.google.common.base.Predicate; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* This abstract class calls {@link #applyNullSafe(Object)} only after success validation of inner object for null | ||
* | ||
* @author lanwen (Merkushev Kirill) | ||
*/ | ||
|
||
public abstract class NullSafePredicate<T> implements Predicate<T> { | ||
|
||
@Override | ||
public boolean apply(T input) { | ||
return applyNullSafe(checkNotNull(input, "Argument for this predicate can't be null")); | ||
} | ||
|
||
/** | ||
* This method will be called inside of {@link #apply(Object)} | ||
*/ | ||
protected abstract boolean applyNullSafe(@Nonnull T input); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters