{"id":17102374,"url":"https://github.com/pierdipi/adapterdesignpattern","last_synced_at":"2025-03-23T19:22:53.818Z","repository":{"id":106871807,"uuid":"147246276","full_name":"pierDipi/AdapterDesignPattern","owner":"pierDipi","description":"Adapter Design Pattern ","archived":false,"fork":false,"pushed_at":"2018-09-03T20:27:59.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T02:45:34.646Z","etag":null,"topics":["adapter-design-pattern","adapter-pattern","design-pattern","design-patterns","java"],"latest_commit_sha":null,"homepage":"https://pierdipi.github.io/AdapterDesignPattern/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pierDipi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-03T19:40:40.000Z","updated_at":"2018-09-03T20:28:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"6ba69ec3-de45-4292-806e-357317ce294a","html_url":"https://github.com/pierDipi/AdapterDesignPattern","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierDipi%2FAdapterDesignPattern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierDipi%2FAdapterDesignPattern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierDipi%2FAdapterDesignPattern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierDipi%2FAdapterDesignPattern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pierDipi","download_url":"https://codeload.github.com/pierDipi/AdapterDesignPattern/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245154909,"owners_count":20569625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adapter-design-pattern","adapter-pattern","design-pattern","design-patterns","java"],"created_at":"2024-10-14T15:28:54.129Z","updated_at":"2025-03-23T19:22:53.807Z","avatar_url":"https://github.com/pierDipi.png","language":"Java","readme":"# Adapter Design Pattern\n\n___\n\nAdapter Design Pattern\n\n\u003e **Convert the interface of a class into another interface clients expect. \n  Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.** \n  \n  \n___  \n\n\n\u003e **Applicability** \n\u003e * Use the Adapter pattern when :\n\u003e   * You want to use an existing class, and its interface does not match the one you need.\n\u003e   * you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces. \n\u003e   * (object adapter only) you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class. \n\n\n___\n\n\n### Example\n\n* Java example (**Book**)\n\n![UML diagram.](/uml/AdapterExample.jpg)\n\n\n___\n\n\n### Usage\n\n```java\nPerson person = new Person();\n\t\t\nperson.read(new Book(\"Book\"));\t\t// Use compatible classes\nperson.turnPage();\nperson.turnPage();\n\t\t\nperson.read(new EReaderAdapter(new Kindle(\"Kindle book\"))); // Use incompatible classes and adapt them.\nperson.turnPage();\nperson.turnPage();\nperson.turnPage();\n\n```\n### Output\n\n```\nOpen the book : Book\nBook: go to the next page : 1\nBook: go to the next page : 2\nTurn on the kindle : Kindle book\nKindle book: go to the next page : 1\nKindle book: go to the next page : 2\nKindle book: go to the next page : 3\n```\n\n___\n\n\n#### Credits \n* [Book](https://en.wikipedia.org/wiki/Design_Patterns)\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierdipi%2Fadapterdesignpattern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpierdipi%2Fadapterdesignpattern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierdipi%2Fadapterdesignpattern/lists"}