com.gregmarut.support.beangenerator.rule.FieldNameRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of test-beangen Show documentation
Show all versions of test-beangen Show documentation
Supports unit testing by dynamically creating bean objects and populating their fields to default values.
/*******************************************************************************
*
* Copyright (c) 2015 Greg Marut.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Greg Marut - initial API and implementation
*
******************************************************************************/
package com.gregmarut.support.beangenerator.rule;
import com.gregmarut.support.beangenerator.value.Value;
public abstract class FieldNameRule extends Rule
{
// holds the pattern of the field name to match
protected final String pattern;
/**
* Creates a new simple Rule to check the pattern against the field name
*
* @param pattern
* @param value
*/
public FieldNameRule(final String pattern, final Value value)
{
super(value);
// make sure the field name is not null
if (null != pattern)
{
this.pattern = pattern;
}
else
{
throw new IllegalArgumentException("pattern cannot be null.");
}
}
/**
* Creates a new simple Rule to check the pattern against the field name
*
* @param pattern
* @param value
*/
public FieldNameRule(final String pattern, final V value)
{
super(value);
// make sure the field name is not null
if (null != pattern)
{
this.pattern = pattern;
}
else
{
throw new IllegalArgumentException("pattern cannot be null.");
}
}
}