001 /* 002 * Copyright 2002-2005 the original author or authors. 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 package org.springframework.binding.validation.support; 017 018 import java.util.Collections; 019 import java.util.Set; 020 021 import org.springframework.binding.validation.ValidationResults; 022 import org.springframework.core.style.ToStringCreator; 023 import org.springframework.richclient.core.Severity; 024 025 /** 026 * An implementation of ValidationResults that contains no results. 027 * 028 * @author Oliver Hutchison 029 */ 030 public class EmptyValidationResults implements ValidationResults { 031 032 /** 033 * The singleton instance of this class. 034 */ 035 public static final ValidationResults INSTANCE = new EmptyValidationResults(); 036 037 protected EmptyValidationResults() { 038 } 039 040 /** 041 * Always returns <code>false</code> 042 */ 043 public boolean getHasErrors() { 044 return false; 045 } 046 047 /** 048 * Always returns <code>false</code> 049 */ 050 public boolean getHasWarnings() { 051 return false; 052 } 053 054 /** 055 * Always returns <code>false</code> 056 */ 057 public boolean getHasInfo() { 058 return false; 059 } 060 061 /** 062 * Always returns 0 063 */ 064 public int getMessageCount() { 065 return 0; 066 } 067 068 /** 069 * Always returns 0 070 */ 071 public int getMessageCount(Severity severity) { 072 return 0; 073 } 074 075 /** 076 * Always returns 0 077 */ 078 public int getMessageCount(String propertyName) { 079 return 0; 080 } 081 082 /** 083 * Always returns an empty list. 084 */ 085 public Set getMessages() { 086 return Collections.EMPTY_SET; 087 } 088 089 /** 090 * Always returns an empty list. 091 */ 092 public Set getMessages(Severity severity) { 093 return Collections.EMPTY_SET; 094 } 095 096 /** 097 * Always returns an empty list. 098 */ 099 public Set getMessages(String propertyName) { 100 return Collections.EMPTY_SET; 101 } 102 103 public String toString() { 104 return new ToStringCreator(this).toString(); 105 } 106 }