001 package com.thaiopensource.validate; 002 003 import com.thaiopensource.util.PropertyId; 004 import com.thaiopensource.util.PropertyMap; 005 import com.thaiopensource.util.PropertyMapBuilder; 006 007 /** 008 * A PropertyId whose value is constrained to be an instance of 009 * String. 010 * 011 * @see String 012 */ 013 014 public class StringPropertyId extends PropertyId { 015 public StringPropertyId(String name) { 016 super(name, String.class); 017 } 018 019 /** 020 * Returns the value of the property. This is a typesafe 021 * version of <code>PropertyMap.get</code>. 022 * 023 * @param properties the PropertyMap to be used 024 * @return the String to which the PropertyMap maps this PropertyId, 025 * or <code>null</code> if this PropertyId is not in the PropertyMap 026 * @see com.thaiopensource.util.PropertyMap#get 027 */ 028 public String get(PropertyMap properties) { 029 return (String)properties.get(this); 030 } 031 032 /** 033 * Sets the value of the property. Modifies the PropertyMapBuilder 034 * so that this PropertyId is mapped to the specified value. This 035 * is a typesafe version of PropertyMapBuilder.put. 036 * 037 * @param builder the PropertyMapBuilder to be modified 038 * @param value the String to which this PropertyId is to be mapped 039 * @return the String to which this PropertyId was mapped before, 040 * or <code>null</code> if it was not mapped 041 * 042 * @see com.thaiopensource.util.PropertyMapBuilder#put 043 */ 044 public String put(PropertyMapBuilder builder, String value) { 045 return (String)builder.put(this, value); 046 } 047 }