MCPcopy Create free account
hub / github.com/aintshy/hub / PgBase

Class PgBase

src/main/java/com/aintshy/pgsql/PgBase.java:52–204  ·  view source on GitHub ↗

Base in PostgreSQL. @author Yegor Bugayenko (yegor@tpc2.com) @version $Id$ @since 0.1 @checkstyle ClassDataAbstractionCouplingCheck (500 lines)

Source from the content-addressed store, hash-verified

50 * @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
51 */
52@Immutable
53@ToString
54@EqualsAndHashCode(of = "src")
55public final class PgBase implements Base {
56
57 /**
58 * Email regex.
59 */
60 private static final Pattern EMAIL = Pattern.compile(
61 "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$",
62 Pattern.CASE_INSENSITIVE
63 );
64
65 /**
66 * Data source.
67 */
68 private final transient PgSource src;
69
70 /**
71 * Ctor.
72 */
73 public PgBase() {
74 this(PgBase.bonecp());
75 }
76
77 /**
78 * Ctor.
79 * @param data Data source
80 */
81 public PgBase(@NotNull final DataSource data) {
82 this.src = new PgSource() {
83 @Override
84 public DataSource get() {
85 return data;
86 }
87 };
88 }
89
90 @Override
91 public Human register(final String email, final String password,
92 final Pocket pocket) throws IOException {
93 if (!PgBase.EMAIL.matcher(email).matches()) {
94 throw new Base.InvalidEmailFormatException(
95 "email format is not correct"
96 );
97 }
98 if (password.length() < Tv.THREE) {
99 throw new Base.InvalidPasswordException(
100 "password is too short, should be at least three letters"
101 );
102 }
103 if (password.length() > Tv.FORTY) {
104 throw new Base.InvalidPasswordException(
105 "password is too long, 40 letters is the maximum"
106 );
107 }
108 Long number;
109 try {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected