惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Secure Thoughts
博客园 - 【当耐特】
Know Your Adversary
Know Your Adversary
NISL@THU
NISL@THU
博客园 - 司徒正美
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
P
Privacy & Cybersecurity Law Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
B
Blog
The GitHub Blog
The GitHub Blog
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
Martin Fowler
Martin Fowler
博客园 - 叶小钗
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Tenable Blog
S
Securelist
博客园 - 三生石上(FineUI控件)
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Security Blog
Microsoft Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
T
Threat Research - Cisco Blogs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
Cloudbric
Cloudbric
The Cloudflare Blog
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
Microsoft Azure Blog
Microsoft Azure Blog
H
Hacker News: Front Page
腾讯CDC
L
Lohrmann on Cybersecurity
C
CERT Recently Published Vulnerability Notes
V2EX - 技术
V2EX - 技术
GbyAI
GbyAI
TaoSecurity Blog
TaoSecurity Blog
I
Intezer
The Last Watchdog
The Last Watchdog
G
GRAHAM CLULEY
Google Online Security Blog
Google Online Security Blog
T
The Blog of Author Tim Ferriss

博客园 - hgdfr

Django1.5内置的用户认证系统介绍(之五)在admin后台管理用户 --by hillfree Django1.5内置的用户认证系统介绍(之四)Authentication in Web requests --by hillfree Django1.5内置的用户认证系统介绍(之三)权限与授权--by hillfree Django1.5内置的用户认证系统介绍(之二)使用User对象--by hillfree Django1.5内置的用户认证系统介绍(之一)--by hillfree Django REST Framework Tutorial 5:关系与超链接API(中文版教程)by hillfree Django REST Framework Tutorial 4:认证与权限(中文版教程)by hillfree Django REST Framework Tutorial 3:基于类的Views(中文版教程)by hillfree Django1.5+Python3.3下groundwork的使用 Django1.5中设置静态目录的简要说明 参照《鲜活的数据:数据可视化指南》第2章:抓取网页数据(历史天气记录)的Python程序 Python3.3中如何产生伪随机数 《鲜活的数据:数据可视化指南》第2章 收集数据 Python3.3源码 CSCW领域的“老”词和“新”词 FOAF简介和朋友圈子 Class Library类型的工程难道不能用app.config? 配置文件中的DataDirectory在那里设置? 注释中如果出现尖括号怎么办?“<” - hgdfr - 博客园 Access Control Issues 有关访问控制
自己写的类需要重写ToString(), HashCode(), Equal()吗?
hgdfr · 2005-08-31 · via 博客园 - hgdfr

在Joshua Bloch的《Effective Java》中是提到需要改写ToString(), 在修改Equal的时候改写HashCode。

在java里面现在可以引入三个apache的类来完成,例如:

 1import org.apache.commons.lang.builder.EqualsBuilder;
 2import org.apache.commons.lang.builder.HashCodeBuilder;
 3import org.apache.commons.lang.builder.ToStringBuilder;
 4
 5    public String toString() {
 6        return new ToStringBuilder(this)
 7            .append("id", getId())
 8            .toString();
 9    }

10
11    public boolean equals(Object other) {
12        if ( (this == other ) ) return true;
13        if ( !(other instanceof TransitionInstance) ) return false;
14        TransitionInstance castOther = (TransitionInstance) other;
15        return new EqualsBuilder()
16            .append(this.getId(), castOther.getId())
17            .isEquals();
18    }

19
20    public int hashCode() {
21        return new HashCodeBuilder()
22            .append(getId())
23            .toHashCode();
24    }

那么就问问:.NET里面需要改写么?有没有类似的函数可以辅助完成呢? 谢谢赐教!

posted @ 2005-08-31 15:31  hgdfr  阅读(1581)  评论(0)    收藏  举报

刷新页面返回顶部