net.sf.uadetector.internal.data.domain
Class DevicePattern.Builder

java.lang.Object
  extended by net.sf.uadetector.internal.data.domain.DevicePattern.Builder
Enclosing class:
DevicePattern

@NotThreadSafe
public static final class DevicePattern.Builder
extends java.lang.Object

Factory that creates instances of DevicePattern via method calls.

Author:
André Rouél

Constructor Summary
DevicePattern.Builder()
           
 
Method Summary
 DevicePattern build()
          Builds a new instance of DevicePattern and returns it.
 DevicePattern.Builder setId(int id)
          Sets the identification number of a device pattern entry.
 DevicePattern.Builder setId(java.lang.String id)
          Sets the identification number (ID) of a device pattern.
 DevicePattern.Builder setPattern(java.util.regex.Pattern pattern)
          Sets a regular expression for a device pattern.
 DevicePattern.Builder setPerlRegularExpression(java.lang.String regex)
          Converts a PERL regular expression in a Java regular expression and sets it in the Builder.
 DevicePattern.Builder setPosition(int position)
          Sets the position of a device pattern in a set of patterns.
 DevicePattern.Builder setPosition(java.lang.String position)
          Sets the position of a device pattern in a set of patterns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DevicePattern.Builder

public DevicePattern.Builder()
Method Detail

build

@Nonnull
public DevicePattern build()
Builds a new instance of DevicePattern and returns it.

Returns:
a new instance of DevicePattern
Throws:
net.sf.qualitycheck.exception.IllegalNegativeArgumentException - if one of the needed arguments to build an instance of DevicePattern is invalid
net.sf.qualitycheck.exception.IllegalNullArgumentException - if one of the needed arguments to build an instance of DevicePattern is invalid

setId

@Nonnull
public DevicePattern.Builder setId(@Nonnegative
                                           int id)
Sets the identification number of a device pattern entry.

Parameters:
id - identification number
Returns:
this Builder, for chaining
Throws:
net.sf.qualitycheck.exception.IllegalNegativeArgumentException - if the given integer is smaller than 0

setId

@Nonnull
public DevicePattern.Builder setId(@Nonnull
                                           java.lang.String id)
Sets the identification number (ID) of a device pattern. The given String is parsed as a decimal number.

Parameters:
id - ID of a device pattern as string
Returns:
this Builder, for chaining
Throws:
net.sf.qualitycheck.exception.IllegalNullArgumentException - if the given argument is null
java.lang.NumberFormatException - if the given string is not parsable as integer
net.sf.qualitycheck.exception.IllegalNegativeArgumentException - if the parsed integer is smaller than 0

setPattern

@Nonnull
public DevicePattern.Builder setPattern(@Nonnull
                                                java.util.regex.Pattern pattern)
Sets a regular expression for a device pattern.

Parameters:
pattern - compiled representation of a regular expression
Returns:
this Builder, for chaining

setPerlRegularExpression

@Nonnull
public DevicePattern.Builder setPerlRegularExpression(@Nonnull
                                                              java.lang.String regex)
Converts a PERL regular expression in a Java regular expression and sets it in the Builder.

Parameters:
regex - PERL style regular expression to be converted
Returns:
this Builder, for chaining

setPosition

@Nonnull
public DevicePattern.Builder setPosition(@Nonnegative
                                                 int position)
Sets the position of a device pattern in a set of patterns.

Parameters:
position - position of a device pattern
Returns:
this Builder, for chaining
Throws:
net.sf.qualitycheck.exception.IllegalNegativeArgumentException - if the given integer is smaller than 0

setPosition

@Nonnull
public DevicePattern.Builder setPosition(@Nonnull
                                                 java.lang.String position)
Sets the position of a device pattern in a set of patterns. The given String is parsed as a decimal number.

Parameters:
position - position of a device pattern as string
Returns:
this Builder, for chaining
Throws:
net.sf.qualitycheck.exception.IllegalNullArgumentException - if the given argument is null
java.lang.NumberFormatException - if the given string is not parsable as integer
net.sf.qualitycheck.exception.IllegalNegativeArgumentException - if the parsed integer is smaller than 0


Copyright © 2011-2014. All Rights Reserved.