［デザインパターン］Javaのコアライブラリ

stackoverflowにあったものを日本語のリンクに修正したもの。（※JavaEEの部分がまだ英語）
よくコアライブラリのソース読んだほうがいいか聞くけど、闇雲に読みのではなくデザインパターンに着目してみた。今後細かく見るためための備忘録。

## 1. Abstract factoryパターン
* [javax.xml.parsers.DocumentBuilderFactory#newInstance()](https://docs.oracle.com/javase/jp/8/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#newInstance--)
* [javax.xml.transform.TransformerFactory#newInstance()](https://docs.oracle.com/javase/jp/8/docs/api/javax/xml/transform/TransformerFactory.html#newInstance--)
* [javax.xml.xpath.XPathFactory#newInstance()](https://docs.oracle.com/javase/jp/6/api/javax/xml/xpath/XPathFactory.html#newInstance())

## 2. Builderパターン
* [java.lang.StringBuilder#append()](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/StringBuilder.html#append-boolean-)
* [java.lang.StringBuffer#append()](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/StringBuffer.html#append-boolean-)
* [java.nio.ByteBuffer#put()](https://docs.oracle.com/javase/jp/8/docs/api/java/nio/ByteBuffer.html)
* [javax.swing.GroupLayout.Group#addComponent()](https://docs.oracle.com/javase/jp/8/docs/api/javax/swing/GroupLayout.Group.html)
* [java.lang.Appendable](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/Appendable.html)


## 3. Factory methodパターン
* [java.util.Calendar#getInstance()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Calendar.html#getInstance--)
* [java.util.ResourceBundle#getBundle()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/ResourceBundle.html#getBundle-java.lang.String-)
* [java.text.NumberFormat#getInstance()](https://docs.oracle.com/javase/jp/8/docs/api/java/text/NumberFormat.html#getInstance--)
* [java.nio.charset.Charset#forName()](https://docs.oracle.com/javase/jp/8/docs/api/java/nio/charset/Charset.html#forName-java.lang.String-)
* [java.net.URLStreamHandlerFactory#createURLStreamHandler(String)](https://docs.oracle.com/javase/jp/8/docs/api/java/net/URLStreamHandlerFactory.html)
* [java.util.EnumSet#of()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/EnumSet.html#of(E))
* [javax.xml.bind.JAXBContext#createMarshaller()](https://docs.oracle.com/javase/jp/8/docs/api/javax/xml/bind/JAXBContext.html#createMarshaller--)

## 4. Prototypeパターン
* [java.lang.Object#clone()](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/Object.html#clone--)

## 5. Singletonパターン
* [java.lang.Runtime#getRuntime()](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/Runtime.html#getRuntime--)
* [java.awt.Desktop#getDesktop()](https://docs.oracle.com/javase/jp/8/docs/api/java/awt/Desktop.html#getDesktop--)
* [java.lang.System#getSecurityManager()](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/System.html#getSecurityManager--)

## 6. Adapterパターン
* [java.util.Arrays#asList()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Arrays.html#asList-T...-)
* [java.util.Collections#list()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Collections.html#list-java.util.Enumeration-)
* [java.util.Collections#enumeration()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Collections.html#enumeration-java.util.Collection-)
* [java.io.InputStreamReader(InputStream) ](https://docs.oracle.com/javase/jp/8/docs/api/java/io/InputStreamReader.html#InputStreamReader-java.io.InputStream-)
* [java.io.OutputStreamWriter(OutputStream)](https://docs.oracle.com/javase/jp/8/docs/api/java/io/OutputStreamWriter.html#OutputStreamWriter-java.io.OutputStream-)
* [javax.xml.bind.annotation.adapters.XmlAdapter#marshal() and #unmarshal()](https://docs.oracle.com/javase/jp/8/docs/api/javax/xml/bind/annotation/adapters/XmlAdapter.html#marshal-BoundType-)

## 7. Bridgeパターン
* [java.util.Collections#newSetFromMap()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Collections.html#newSetFromMap-java.util.Map-)
* [java.util.Collections#singletonXXX()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Collections.html#singleton-T-)

## 8. Compositeパターン
* [java.awt.Container#add(Component) ](https://docs.oracle.com/javase/jp/8/docs/api/java/awt/Container.html#add-java.awt.Component-)
* [javax.faces.component.UIComponent#getChildren()](https://docs.oracle.com/javaee/7/api/javax/faces/component/UIComponent.html#getChildren--)

## 9. Decoratorパターン
* [java.io.InputStream](https://docs.oracle.com/javase/jp/8/docs/api/java/io/InputStream.html)
* [java.io.OutputStream](https://docs.oracle.com/javase/jp/8/docs/api/java/io/OutputStream.html)
* [java.util.Collections  checkedXXX(), synchronizedXXX() and unmodifiableXXX()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Collections.html)
* [javax.servlet.http.HttpServletRequestWrapper and HttpServletResponseWrapper](http://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequestWrapper.html)

## 10. Facadeパターン
* [javax.faces.context.FacesContext LifeCycle, ViewHandler, NavigationHandler](https://docs.oracle.com/javaee/7/api/javax/faces/context/FacesContext.html)
* [javax.faces.context.ExternalContext ServletContext, HttpSession, HttpServletRequest, HttpServletResponse, etc.](https://docs.oracle.com/javaee/7/api/javax/faces/context/ExternalContext.html)

## 11. Flyweightパターン
* [java.lang.Integer#valueOf(int)](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/Integer.html#valueOf-int-)

## 12. Proxyパターン
* [java.lang.reflect.Proxy](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/reflect/Proxy.html)
* [java.rmi.*](https://docs.oracle.com/javase/jp/8/docs/api/java/rmi/package-summary.html)
* [javax.ejb.EJB](https://docs.oracle.com/javaee/7/api/javax/ejb/EJB.html)
* [javax.inject.Inject](https://docs.oracle.com/javaee/7/api/javax/inject/Inject.html)
* [javax.persistence.PersistenceContext](http://docs.oracle.com/javaee/7/api/javax/persistence/PersistenceContext.html)

## 13. Chain of responsibility パターン
* [java.util.logging.Logger#log()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/logging/Logger.html#log-java.util.logging.Level-java.lang.String-)
* [javax.servlet.Filter#doFilter()](https://docs.oracle.com/javaee/7/api/javax/servlet/Filter.html#doFilter-javax.servlet.ServletRequest-javax.servlet.ServletResponse-javax.servlet.FilterChain-)

## 14. Commandパターン
* [java.lang.Runnable](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/Runnable.html)
* [javax.swing.Action](https://docs.oracle.com/javase/jp/8/docs/api/javax/swing/Action.html)

## 15. Interpreterパターン
* [java.util.Pattern](https://docs.oracle.com/javase/jp/8/docs/api/java/util/regex/Pattern.html)
* [java.text.Normalizer](https://docs.oracle.com/javase/jp/8/docs/api/java/text/Normalizer.html)
* [java.text.Format](https://docs.oracle.com/javase/jp/8/docs/api/java/text/Format.html)
* [javax.el.ELResolver](https://docs.oracle.com/javaee/7/api/javax/el/ELResolver.html)

## 16. Iteratorパターン
* [java.util.Iterator](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Iterator.html)
* [java.util.Enumeration](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Enumeration.html)

## 17. Mediatorパターン
* [java.util.Timer](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Timer.html)
* [java.util.concurrent.Executor#execute()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/concurrent/Executor.html#execute-java.lang.Runnable-)
* [java.util.concurrent.ExecutorService](https://docs.oracle.com/javase/jp/8/docs/api/java/util/concurrent/ExecutorService.html)
* [java.util.concurrent.ScheduledExecutorService](https://docs.oracle.com/javase/jp/8/docs/api/java/util/concurrent/ScheduledExecutorService.html)
* [java.lang.reflect.Method#invoke()](https://docs.oracle.com/javase/jp/8/docs/api/java/lang/reflect/Method.html#invoke-java.lang.Object-java.lang.Object...-)

## 18. Mementoパターン
* [java.util.Date](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Date.html)
* [java.io.Serializable](https://docs.oracle.com/javase/jp/8/docs/api/java/io/Serializable.html)
* [javax.faces.component.StateHolder](https://docs.oracle.com/javaee/7/api/javax/faces/component/StateHolder.html)

## 19. Observerパターン
* [java.util.Observer](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Observer.html)
* [java.util.Observable](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Observable.html)
* [java.util.EventListener](https://docs.oracle.com/javase/jp/8/docs/api/java/util/EventListener.html)
* [javax.servlet.http.HttpSessionBindingListener](https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpSessionBindingListener.html)
* [javax.servlet.http.HttpSessionAttributeListener](https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpSessionAttributeListener.html)
* [javax.faces.event.PhaseListener](https://docs.oracle.com/javaee/7/api/javax/faces/event/PhaseListener.html)

## 20. Stateパターン
* [javax.faces.lifecycle.LifeCycle#execute()](https://docs.oracle.com/javaee/7/api/javax/faces/lifecycle/Lifecycle.html#execute-javax.faces.context.FacesContext-)

## 21. Strategyパターン
* [java.util.Comparator#compare()](https://docs.oracle.com/javaee/7/api/javax/faces/lifecycle/Lifecycle.html#execute-javax.faces.context.FacesContext-)
* [javax.servlet.http.HttpServlet](https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServlet.html)
* [javax.servlet.Filter#doFilter()](https://docs.oracle.com/javaee/7/api/javax/servlet/Filter.html#doFilter-javax.servlet.ServletRequest-javax.servlet.ServletResponse-javax.servlet.FilterChain-)

## 22. Template method パターン
* [java.io.InputStream](https://docs.oracle.com/javase/jp/8/docs/api/java/io/InputStream.html)
* [java.io.OutputStream](https://docs.oracle.com/javase/jp/8/docs/api/java/io/OutputStream.html)
* [java.io.Reader](https://docs.oracle.com/javase/jp/8/docs/api/java/io/Reader.html)
* [java.io.Writer](https://docs.oracle.com/javase/jp/8/docs/api/java/io/Writer.html)
* [java.util.AbstractList](https://docs.oracle.com/javase/jp/8/docs/api/java/util/AbstractList.html)
* [java.util.AbstractSet](https://docs.oracle.com/javase/jp/8/docs/api/java/util/AbstractSet.html)
* [java.util.AbstractMap](https://docs.oracle.com/javase/jp/8/docs/api/java/util/AbstractMap.html)
* [javax.servlet.http.HttpServlet](https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServlet.html)

## 23. Visitorパターン
* [javax.lang.model.element.AnnotationValue](https://docs.oracle.com/javase/jp/8/docs/api/javax/lang/model/element/AnnotationValue.html)  and
[javax.lang.model.element.AnnotationValueVisitor](https://docs.oracle.com/javase/jp/8/docs/api/javax/lang/model/element/AnnotationValueVisitor.html)

* [javax.lang.model.element.Element](https://docs.oracle.com/javase/jp/8/docs/api/javax/lang/model/element/Element.html)  and
[javax.lang.model.element.ElementVisitor](https://docs.oracle.com/javase/jp/8/docs/api/javax/lang/model/element/ElementVisitor.html)

* [javax.lang.model.type.TypeMirror](https://docs.oracle.com/javase/jp/8/docs/api/javax/lang/model/type/TypeMirror.html)  and
[javax.lang.model.type.TypeVisitor](https://docs.oracle.com/javase/jp/8/docs/api/javax/lang/model/type/TypeVisitor.html)

* [java.nio.file.FileVisitor](https://docs.oracle.com/javase/jp/8/docs/api/java/nio/file/FileVisitor.html)  and
[java.nio.file.SimpleFileVisitor](https://docs.oracle.com/javase/jp/8/docs/api/java/nio/file/SimpleFileVisitor.html)

* [javax.faces.component.visit.VisitContext](https://docs.oracle.com/javaee/7/api/javax/faces/component/visit/VisitContext.html)  and
[javax.faces.component.visit.VisitCallback](https://docs.oracle.com/javaee/7/api/javax/faces/component/visit/VisitCallback.html)

---
参考：https://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns-in-javas-core-libraries