肉松饼罗曼史 2017-03-13 08:12 采纳率: 42.9%
浏览 2105
已采纳

java枚举类型的构造方法处理

我知道构造函数怎么写,但是枚举类型,枚举其他的对象,这里应该怎么添加呢?能不能给我以id为例,进行枚举的构造方法添加啊?不胜感激啊
package com.java;

public class Locator {
private String element;

private int waitSec;

public enum ByType {
    xpath, id, linkText, name, className, cssSelector, partialLinkText, tagName
}

private ByType byType;

public Locator() {

}


public Locator(String element) {
    this.element = element;
    this.waitSec = 3;
    this.byType = ByType.xpath;

}

public Locator(String element, int waitSec) {
    this.waitSec = waitSec;
    this.element = element;
    this.byType = ByType.xpath;

}



public Locator(String element, int waitSec, ByType byType) {
    this.waitSec = waitSec;
    this.element = element;
    this.byType = byType;
}

public String getElement() {
    return element;
}

public int getWaitSec() {
    return waitSec;
}

public ByType getBy() {
    return byType;
}

public void setBy(ByType byType) {
    this.byType = byType;
}

public void setReplace(String rep, String rex)
{
    StringTools.replaceAll(element, rex, rep);
}

}

  • 写回答

1条回答

  • 夕阳雨晴 2017-03-13 08:21
    关注

    public enum ByType {
    xpath, linkText, name, className, cssSelector, partialLinkText, tagName
    private String id;
    public ByType(String id){
    this.id=id;
    }
    }

    可以参考这篇文章。http://blog.csdn.net/vvhesj/article/details/45394587

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码