001// -------------------------------------------------------------------------------- 002// Copyright 2002-2024 Echo Three, LLC 003// 004// Licensed under the Apache License, Version 2.0 (the "License"); 005// you may not use this file except in compliance with the License. 006// You may obtain a copy of the License at 007// 008// http://www.apache.org/licenses/LICENSE-2.0 009// 010// Unless required by applicable law or agreed to in writing, software 011// distributed under the License is distributed on an "AS IS" BASIS, 012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013// See the License for the specific language governing permissions and 014// limitations under the License. 015// -------------------------------------------------------------------------------- 016 017package com.echothree.util.common.command; 018 019import com.echothree.util.common.message.ExecutionErrors; 020import com.echothree.util.common.message.Messages; 021import java.io.Serializable; 022 023public class ExecutionResult 024 implements Serializable { 025 026 private Messages executionWarnings; 027 private Messages executionErrors; 028 private BaseResult result; 029 030 /** Creates a new instance of ExecutionResult */ 031 public ExecutionResult(Messages executionWarnings, Messages executionErrors, BaseResult result) { 032 this.executionWarnings = executionWarnings; 033 this.executionErrors = executionErrors; 034 this.result = result; 035 } 036 037 public Messages getExecutionWarnings() { 038 return executionWarnings; 039 } 040 041 public Messages getExecutionErrors() { 042 return executionErrors; 043 } 044 045 public Boolean getHasLockErrors() { 046 return executionErrors == null ? false 047 : executionErrors.containsKeys(Messages.EXECUTION_ERROR, ExecutionErrors.EntityLockFailed.name(), ExecutionErrors.EntityLockStale.name()); 048 } 049 050 public Boolean getHasWarnings() { 051 return executionWarnings == null? false: executionWarnings.size(Messages.EXECUTION_WARNING) != 0; 052 } 053 054 public Boolean getHasErrors() { 055 return executionErrors == null? false: executionErrors.size(Messages.EXECUTION_ERROR) != 0; 056 } 057 058 public Boolean getHasResults() { 059 return result != null; 060 } 061 062 public BaseResult getResult() { 063 return result; 064 } 065 066 @Override 067 public String toString() { 068 return new StringBuilder().append("{ executionWarnings = ").append(executionWarnings).append(", executionErrors = "). 069 append(executionErrors).append(", result = ").append(result).append(" }").toString(); 070 } 071 072}