1 /* 2 * Copyright (c) 2012-2023, jcabi.com 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 1) Redistributions of source code must retain the above 8 * copyright notice, this list of conditions and the following 9 * disclaimer. 2) Redistributions in binary form must reproduce the above 10 * copyright notice, this list of conditions and the following 11 * disclaimer in the documentation and/or other materials provided 12 * with the distribution. 3) Neither the name of the jcabi.com nor 13 * the names of its contributors may be used to endorse or promote 14 * products derived from this software without specific prior written 15 * permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 19 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 * OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 package com.jcabi.mysql.maven.plugin; 31 32 import java.util.Collections; 33 import java.util.List; 34 import javax.validation.constraints.NotNull; 35 import lombok.EqualsAndHashCode; 36 import lombok.ToString; 37 38 /** 39 * Configuration POJO. 40 * 41 * <p>Contains configuration for particular db instance {@link Instances}.</p> 42 * 43 * @since 0.6 44 */ 45 @ToString 46 @EqualsAndHashCode( 47 of = { "tcpport", "dbuser", "dbpassword", "name", "dbopts" } 48 ) 49 public final class Config { 50 51 /** 52 * TCP port. 53 */ 54 private final transient int tcpport; 55 56 /** 57 * Db user name. 58 */ 59 private final transient String dbuser; 60 61 /** 62 * Db password. 63 */ 64 private final transient String dbpassword; 65 66 /** 67 * Db name. 68 */ 69 private final transient String name; 70 71 /** 72 * Configuration options. 73 */ 74 private final transient List<String> dbopts; 75 76 /** 77 * Creates new configuration. 78 * @param port TCP port 79 * @param usr Db user name 80 * @param password Db password 81 * @param dbn Db name 82 * @param opts Configuration options 83 * @checkstyle ParameterNumberCheck (15 lines) 84 */ 85 public Config( 86 final int port, 87 @NotNull final String usr, 88 @NotNull final String password, 89 @NotNull final String dbn, 90 @NotNull final List<String> opts 91 ) { 92 this.tcpport = port; 93 this.dbuser = usr; 94 this.dbpassword = password; 95 this.name = dbn; 96 this.dbopts = Collections.unmodifiableList(opts); 97 } 98 99 /** 100 * Get TCP port we're on. 101 * @return Port number 102 */ 103 public int port() { 104 return this.tcpport; 105 } 106 107 /** 108 * Get Db user name. 109 * @return User name 110 */ 111 public String user() { 112 return this.dbuser; 113 } 114 115 /** 116 * Get Db password. 117 * @return Password 118 */ 119 public String password() { 120 return this.dbpassword; 121 } 122 123 /** 124 * Get Db name. 125 * @return Database name 126 */ 127 public String dbname() { 128 return this.name; 129 } 130 131 /** 132 * Get configuration options. 133 * @return Options 134 */ 135 public List<String> options() { 136 return this.dbopts; 137 } 138 }