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

de.ec.sql.Having Maven / Gradle / Ivy

There is a newer version: 1.2
Show newest version
package de.ec.sql;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

@NoArgsConstructor
@Setter(AccessLevel.PROTECTED)
@Accessors(fluent = true)
public class Having extends Conditionable implements QueryBuilder, BeforeOrderBy {

	private BeforeHaving builder;
	private Conditionable condition;
	private String sql;

	protected Having(final BeforeHaving builder) {
		this.builder = builder;
	}

	@Override
	public String string() {
		return string(QueryOptions.DEFAULT_OPTIONS);
	}

	@Override
	public String string(final QueryOptions options) {
		final StringJoiner strings = new StringJoiner();

		if (builder != null)
			strings.add(builder.string(options));

		if (sql != null) {
			strings.add(sql);
		} else {
			if (condition != null) {
				strings.add(options.newLine());
				strings.add(options.padCased("HAVING"));
				strings.add(" ");
				strings.add(condition.string(options));
			}
		}

		return strings.toString();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy