-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/main/java/com/dongho/df/domain/structural/adapter/Alarm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.dongho.df.domain.structural.adapter; | ||
|
||
import java.io.File; | ||
|
||
public interface Alarm { | ||
|
||
void sendText(String text); | ||
void sendMessage(File image); | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/dongho/df/domain/structural/adapter/MailAlarm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.dongho.df.domain.structural.adapter; | ||
|
||
import java.io.File; | ||
|
||
public class MailAlarm implements Alarm { | ||
|
||
@Override | ||
public void sendText(String text) { | ||
System.out.println("send text"); | ||
} | ||
|
||
@Override | ||
public void sendMessage(File image) { | ||
System.out.println("send " + image.getName()); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/dongho/df/domain/structural/adapter/SmsAlarm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.dongho.df.domain.structural.adapter; | ||
|
||
import java.io.File; | ||
|
||
public class SmsAlarm implements Alarm { | ||
|
||
private SmsTransferLib smsTransferLib; | ||
|
||
public SmsAlarm(SmsTransferLib smsTransferLib) { | ||
this.smsTransferLib = smsTransferLib; | ||
} | ||
|
||
@Override | ||
public void sendText(String text) { | ||
smsTransferLib.sendMessage(text.toCharArray()); | ||
} | ||
|
||
@Override | ||
public void sendMessage(File image) { | ||
smsTransferLib.sendMessage("".toCharArray(), image); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/dongho/df/domain/structural/adapter/SmsTransferLib.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.dongho.df.domain.structural.adapter; | ||
|
||
import java.io.File; | ||
|
||
public class SmsTransferLib { | ||
|
||
public void sendMessage(char[] message) { | ||
System.out.println(message); | ||
} | ||
|
||
public void sendMessage(char [] message, File image) { | ||
System.out.println(message + image.getName()); | ||
} | ||
|
||
} |