javaDSL簡單實現(xiàn)示例分享
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;
}
}
相關(guān)文章
SpringBoot使用@EnableAutoConfiguration實現(xiàn)自動配置詳解
你有想過SpringBoot為什么能夠自動的幫我們創(chuàng)建一個Bean對象么?或許在我們使用的時候只需要在自己自定義的配置文件中加入@Bean對象就可以,但SpringBoot是如何來創(chuàng)建的呢2022-08-08
SpringBoot+Email發(fā)送郵件的實現(xiàn)示例
Spring?Boot提供了簡單而強大的郵件發(fā)送功能,本文主要介紹了SpringBoot+Email發(fā)送郵件的實現(xiàn)示例,具有一定的參考價值,感興趣的可以了解一下2024-03-03
SpringBoot中讀取jar包中的resources目錄下的文件的三種方式
這篇文章給大家總結(jié)了SpringBoot讀取 jar 包中的 resources 目錄下的文件的三種方式,文中有詳細的代碼示例供大家參考,,需要的朋友可以參考下2023-06-06
解讀Java中打印輸出對象內(nèi)容為什么可以不寫.toString()
這篇文章主要介紹了解讀Java中打印輸出對象內(nèi)容為什么可以不寫.toString()問題,具有很的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-09-09
java 輸入一個數(shù)字,反轉(zhuǎn)輸出這個數(shù)字的值(實現(xiàn)方法)
下面小編就為大家?guī)硪黄猨ava 輸入一個數(shù)字,反轉(zhuǎn)輸出這個數(shù)字的值(實現(xiàn)方法)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-10-10

