All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.infusers.core.secrets.dto.RabbitMQSecrets Maven / Gradle / Ivy

package com.infusers.core.secrets.dto;

import org.springframework.stereotype.Component;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Component
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class RabbitMQSecrets implements ISecrets {
	private String username;
	private String password;
	private String host;
	private String port;
	
	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public String getPort() {
		return port;
	}

	public void setPort(String port) {
		this.port = port;
	}

	public String getUsername() {
		return username;
	}

	public String getPassword() {
		return password;
	}
	
    public boolean isValid() {
        return isValidField(username) &&
               isValidField(password) &&
               isValidField(host) &&
               isValidPort(port);
    }

    private boolean isValidField(String field) {
        return field != null && !field.isEmpty();
    }

    private boolean isValidPort(String port) {
        try {
            int portNumber = Integer.parseInt(port);
            return portNumber > 0 && portNumber <= 65535; // Port range is 1-65535
        } catch (NumberFormatException e) {
            return false; // Not a valid integer
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy