javaDSL简单实现示例分享
package com.vd.dsl;
import static com.vd.dsl.GraphBuilder.*;
public class Main {
public static void main(String[] args) {
Graph().edge().from("a").to("b").weigth(20.0).edge().from("b").to("c").weigth(10.0).printGraph();
}
}
package com.vd.dsl;
public class Edge {
private Vertex fromVertex;
private Vertex toVertex;
public Vertex getFromVertex() {
return fromVertex;
}
public void setFromVertex(Vertex fromVertex) {
this.fromVertex = fromVertex;
}
public Vertex getToVertex() {
return toVertex;
}
public void setToVertex(Vertex toVertex) {
this.toVertex = toVertex;
}
public Double getWeight() {
return weight;
}
public void setWeight(Double weight) {
this.weight = weight;
}
private Double weight;
public Edge() {
}
@Override
public String toString() {
return fromVertex.getLabel()+ " to "+
toVertex.getLabel() + "with weigth "+
this.weight;
}
}
相关文章
SpringBoot使用@EnableAutoConfiguration实现自动配置详解
你有想过SpringBoot为什么能够自动的帮我们创建一个Bean对象么?或许在我们使用的时候只需要在自己自定义的配置文件中加入@Bean对象就可以,但SpringBoot是如何来创建的呢2022-08-08
SpringBoot中读取jar包中的resources目录下的文件的三种方式
这篇文章给大家总结了SpringBoot读取 jar 包中的 resources 目录下的文件的三种方式,文中有详细的代码示例供大家参考,,需要的朋友可以参考下2023-06-06
解读Java中打印输出对象内容为什么可以不写.toString()
这篇文章主要介绍了解读Java中打印输出对象内容为什么可以不写.toString()问题,具有很的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2023-09-09


最新评论