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

de.ec.sql.Where 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 Where extends Conditionable
		implements QueryBuilder, BeforeGroupBy, BeforeOrderBy {

	private BeforeWhere builder;
	private String sql;

	protected Where(final BeforeWhere 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 {
			final String condition = super.string(options);

			if (condition != null && !condition.isEmpty()) {
				strings.add(options.newLine());
				strings.add(options.padCased("WHERE"));
				strings.add(" ");
				strings.add(condition);
			}
		}

		return strings.toString();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy