Created
February 16, 2022 02:50
-
-
Save sebassdc/9e187683ea41dd67fe8a9b300215fcdf to your computer and use it in GitHub Desktop.
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
// private static String MATRIX_NON_NULL_AND_ACTIVE_NON_NULL = "matrix non null and active non null"; | |
// private static String MATRIX_NULL_AND_ACTIVE_NON_NULL = "matrix null and active non null"; | |
// private static String MATRIX_NULL_AND_ACTIVE_NULL = "matrix null and active null"; | |
// private static String EXCEPTION = "Add a value for active or leave empty matrix too"; | |
// public String searchForUserAndRole(String matrix, String active) { | |
// String response = ""; | |
// if (matrix != null && active != null) { | |
// response = MATRIX_NON_NULL_AND_ACTIVE_NON_NULL; | |
// } else if (matrix == null && active != null) { | |
// response = MATRIX_NULL_AND_ACTIVE_NON_NULL; | |
// } else if (matrix == null && active == null) { | |
// response = MATRIX_NULL_AND_ACTIVE_NULL; | |
// } else { | |
// throw new RuntimeException(EXCEPTION); | |
// } | |
// return response; | |
// } | |
private static String EXCEPTION = "Add a value for active or leave empty matrix too"; | |
private static String MATRIX_NULL_TEXT = "matrix null"; | |
private static String MATRIX_NON_NULL_TEXT = "matrix non null"; | |
private static String ACTIVE_NULL_TEXT = "active null"; | |
private static String ACTIVE_NON_NULL_TEXT = "active non null"; | |
public String searchForUserAndRole(String matrix, String active) { | |
Boolean isActiveNotNull = active != null; | |
Boolean isMatrixNotNull = matrix != null; | |
if (isMatrixNull && !isActiveNotNull) throw new RuntimeException(EXCEPTION); | |
String matrixText = isMatrixNotNull ? MATRIX_NON_NULL_TEXT : MATRIX_NULL_TEXT; | |
String activeText = isActiveNotNull ? ACTIVE_NON_NULL_TEXT : ACTIVE_NULL_TEXT; | |
String response = matrixText + " and " + activeText; | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment