View Javadoc
1   package com.srv4pos.server.api.infrastructure;
2   
3   import org.springframework.roo.addon.javabean.RooJavaBean;
4   import org.springframework.roo.addon.json.RooJson;
5   import org.springframework.roo.addon.tostring.RooToString;
6   
7   import javax.validation.constraints.NotNull;
8   import javax.validation.constraints.Pattern;
9   import javax.validation.constraints.Size;
10  
11  /**
12   * Methods called "new" will return the identifier of newly created entity by using this class.
13   * <p>User: Kirill, Date: 14.09.13 14:55</p>
14   */
15  @RooJavaBean
16  @RooToString
17  @RooJson(deepSerialize = true)
18  public class IdentifierInfo implements Info {
19      public static final String ALLOWED_LETTERS = "0123456789ABCDEFGHJKLMNPRSTUWXYZ";
20      /**
21       * It has format {serverId}-{autoincrementId}. Where serverId - unique id of the server,
22       * autoincrementId - just +1 unique long id within the server.
23       * Both identifiers are in scale of notation with basis 32. To serialize number to the string
24       * {@link #ALLOWED_LETTERS} array used. Use {@link com.srv4pos.server.api.infrastructure.http.HttpHelper#shortify(long)} to serialize.     *
25       */
26      @NotNull
27      @Size(max = 50, min = 1)
28      @Pattern(regexp = Constraints.WINDOWS_FILENAME_REGEX)
29      private String identifier;
30  
31      public static IdentifierInfo of(String identifier) {
32          final IdentifierInfo identifierInfo = new IdentifierInfo();
33          identifierInfo.setIdentifier(identifier);
34          return identifierInfo;
35      }
36  }