001/** 002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com). 003 * <p> 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 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 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 */ 016package io.jboot.components.valid.interceptor; 017 018import com.jfinal.kit.Ret; 019 020import javax.validation.ConstraintTarget; 021import javax.validation.ConstraintValidator; 022import javax.validation.MessageInterpolator; 023import javax.validation.Payload; 024import javax.validation.metadata.ConstraintDescriptor; 025import javax.validation.metadata.ValidateUnwrappedValue; 026import java.lang.annotation.Annotation; 027import java.util.HashMap; 028import java.util.List; 029import java.util.Map; 030import java.util.Set; 031 032public class SimpleContext implements MessageInterpolator.Context{ 033 034 private Map<String, Object> attrs = new HashMap(); 035 private ConstraintDescriptor constraintDescriptor = new ConstraintDescriptor() { 036 @Override 037 public Annotation getAnnotation() { 038 return null; 039 } 040 041 @Override 042 public String getMessageTemplate() { 043 return null; 044 } 045 046 @Override 047 public Set<Class<?>> getGroups() { 048 return null; 049 } 050 051 @Override 052 public Set<Class<? extends Payload>> getPayload() { 053 return null; 054 } 055 056 @Override 057 public ConstraintTarget getValidationAppliesTo() { 058 return null; 059 } 060 061 @Override 062 public List<Class<? extends ConstraintValidator>> getConstraintValidatorClasses() { 063 return null; 064 } 065 066 @Override 067 public Map<String, Object> getAttributes() { 068 return attrs; 069 } 070 071 @Override 072 public Set<ConstraintDescriptor<?>> getComposingConstraints() { 073 return null; 074 } 075 076 @Override 077 public boolean isReportAsSingleViolation() { 078 return false; 079 } 080 081 @Override 082 public ValidateUnwrappedValue getValueUnwrapping() { 083 return null; 084 } 085 086 @Override 087 public Object unwrap(Class type) { 088 return null; 089 } 090 }; 091 092 public SimpleContext() { 093 } 094 095 public SimpleContext(Ret attrs) { 096 if (attrs != null){ 097 this.attrs.putAll(attrs); 098 } 099 } 100 101 102 @Override 103 public ConstraintDescriptor<?> getConstraintDescriptor() { 104 return constraintDescriptor; 105 } 106 107 @Override 108 public Object getValidatedValue() { 109 return null; 110 } 111 112 @Override 113 public <T> T unwrap(Class<T> type) { 114 return null; 115 } 116 117 118}