I have code where I validate deviceId and clientId basis on what ProcessType is coming:  public static boolean isValid(ProcessType processType, Record record) {    String deviceId = DataUtils.extract(record, deviceId);    String clientId =DataUtils.extract(record, clientId);    if(processType == ProcessType.ABC || processType == ProcessType.DEF) {        if (Strings.isNullOrEmpty(clientId) || Strings.isNullOrEmpty(deviceId)) {        LogMetric.getInstance().increment(processType.name(), Metric.ID);        logger.logError(invalid clientId and deviceId provided. ProcessType= , processType,            , Record= , record);                    return false;        }    } else {        if (Strings.isNullOrEmpty(clientId) && Strings.isNullOrEmpty(deviceId)) {        LogMetric.getInstance().increment(processType.name(), Metric.ID);        logger.logError(invalid clientId and deviceId provided. ProcessType= , processType,            , Record= , record);                    return false;        }       }    return true;  }If ProcessType is coming as ABC or DEF, then I will return false if clientId or deviceId is missing Otherwise I will return false if both clientId and deviceId are missing. If all the conditions are not met, then I will return true.I wanted to see if there is any better way to write this. I'm working with Java 7.
Validate particular id's depending on what process type is coming
java;validation
Except the  wrong indentation in your deepest if there is nothing much to do. But :You can create a isSpecificProcess(ProcessType):boolean method that contains the processType == ProcessType.ABC || processType == ProcessType.DEF condition. Il will explain the meaning of your test for a newcomer in your business.You can also extract the logging to a specific method because the two blocks are identical.Aside of that I can't see anything more to say.