There is an entity class Ga1400Person
that contains the person name, and idNumber fields
public class Ga1400Person {
private String name;
private String idNumber;
}
The characteristic string of a layout object is defined as follows:
- using multiple key-value pairs
((Key1=Value1) and (Key2=Value2)) or (Key3=Value3)
formula to represent the refinement conditions corresponding to the category; - The value of Key is derived from the
PropertyTypeEnum enum
.
3, support fuzzy layout control: regular expression symbol “?
Common regular expression characters such as,*
,and
,or
,()
“;
4, the punctuation symbols involved in the formula are English half corner;
The PropertyType
enumeration is as follows:
public enum PropertyTypeEnum {
PERSON_NAME(1, "person name"),
ID_NUMBER(2, "ID number"),
PLATE_NO(3, "license plate"),
PLATE_COLOR(4, "license plate color"),
VEHICLE_BRAND(5, "Vehicle brand"),
VEHICLE_MODEL(6, "Vehicle model"),
VEHICLE_STYLES(7, "Vehicle year"),
KEYWORK(8, "keyword");
private Integer value;
private String desc;
}
Write a method checkPerson
, take the entity class Ga1400Person
, return the Boolean
value,
Resolve whether the Person
name
and idNumber
of the entity class Person
conform to the regular expression rules of the feature string of the controller object. If yes, return true
. If no, return false
Illustrate by example
(1= white) and (2=123456)
If the character string of the preceding control object is correctly interpreted as the name is blank and the idnumber is 123456
, return true
((1= white) and (2=123456)) or (1= three)
The above feature string is correctly interpreted as true
if the name
is blank and the ID number is 123456
, or if the name
is three
Illustrate by example
// The following character string of a layout object is featureString. // If the name is blank and the ID number is 123456, or the name is three, the value is true
String featureString = "((1= nothing) and (2=123456)) or (1= three pieces)";
Test method expectation
public static void main(String[] args) {
// The character string of the controller object
String featureString = "((1= nothing) and (2=123456)) or (1= three pieces)";
// Create a Ga1400Person instance
Ga1400Person person1 = new Ga1400Person(" white up ", "123456");
Ga1400Person person2 = new Ga1400Person(" Zhang SAN ", "789012");
// Check whether the feature string rules of the controlled object are complied with
boolean result1 = checkPerson(person1, featureString);
boolean result2 = checkPerson(person2, featureString);
System.out.println("Person1 conforms to the feature string rule of the controller object: "+ result1);
System.out.println("Person2 conforms to the character string rule of the controller object: "+ result2);
}
Expect both result1
and result2
to be true
JourWon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3