com.sqlapp.graphviz.schemas.AbstractSchemaGraphBuilder Maven / Gradle / Ivy
/**
* Copyright (C) 2007-2017 Tatsuo Satoh
*
* This file is part of sqlapp-graphviz.
*
* sqlapp-graphviz is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sqlapp-graphviz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with sqlapp-graphviz. If not, see .
*/
package com.sqlapp.graphviz.schemas;
import java.util.function.Consumer;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
@Accessors(fluent = true, chain=true)
@Getter
@Setter
public class AbstractSchemaGraphBuilder {
private DrawOptions drawOption=new DrawOptions();
@Getter(lombok.AccessLevel.PROTECTED)
@Setter(lombok.AccessLevel.PROTECTED)
private AbstractSchemaGraphBuilder parent;
protected T getRoot(){
return getParent(this);
}
protected DrawOptions getDrawOption(){
AbstractSchemaGraphBuilder root=this.getRoot();
if (root!=this){
return root.getDrawOption();
}
return drawOption;
}
@SuppressWarnings("unchecked")
public T drawOption(Consumer cons) {
cons.accept(this.getDrawOption());
return (T)this;
}
@SuppressWarnings("unchecked")
protected T getParent(AbstractSchemaGraphBuilder element){
if (element.parent()==null){
return (T)element;
}
return (T)getParent(element.parent());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy